silkaj issueshttps://git.duniter.org/clients/python/silkaj/-/issues2023-11-13T16:29:05+01:00https://git.duniter.org/clients/python/silkaj/-/issues/256Implement `excluded` command to report excluded identities from the WoT / Dea...2023-11-13T16:29:05+01:00MoulImplement `excluded` command to report excluded identities from the WoT / DeathReaper- [Forum post](https://forum.duniter.org/t/je-me-presente-je-suis-deathreaper-alias-la-faucheuse/6539)
- [Crowdfunding](https://moul.re/moul/silkaj.html)
## Tasks
### Message generation
- [x] Generate markdown output
- [x] [Improve gene...- [Forum post](https://forum.duniter.org/t/je-me-presente-je-suis-deathreaper-alias-la-faucheuse/6539)
- [Crowdfunding](https://moul.re/moul/silkaj.html)
## Tasks
### Message generation
- [x] Generate markdown output
- [x] [Improve generated output for more readability](https://forum.duniter.org/t/exclusions-de-la-toile-de-confiance-g1-expirations-des-statuts-de-membre/4393/652?u=moul):
```bash
### Exclusions de la toile de confiance Ğ1, pertes des statuts de membre
> Message automatique. Merci de notifier vos proches de leur exclusion de la toile de confiance
- [`Williambenhaim`](https://g1.duniter.fr/#/app/block/274234/7D4334A459D6F35A089492D346B07C6711AFB0E8273CE9DCE3BC65C594061A25?ssl=true) :
- **certifié·e par** Jonelio108, Gauri, Djtina12.
- **a certifié·e** Jonelio108, Gauri, Djtina12.
- [bloc](https://g1.duniter.fr/#/app/block/278701/4C83465A475FF97AA48125CB8567BD7AE5EFCAE35DEF6819DE22826306C0C5A3?ssl=true) :
- @Helene:
- **certifié·e par** @ElenaMoshkina, @bert, @Notfifi, @Floweranne, @Gabychou, @dagasaga, @AnaisTerraFlor.
- **a certifié·e** Jonelio108, Gauri, Djtina12.
- @Valentina:
- **certifié·e par** @ElenaMoshkina, @bert, @Notfifi, @Gabychou, @Floweranne, @AnaisTerraFlor, @dagasaga.
- **a certifié·e** Jonelio108, Gauri, Djtina12.
```
- [ ] One post per block/exclusion? Could ease not to loose exclusions around 9AM/PM.
- [ ] [The exclusion through WebSocket event would be nice on GVA](https://forum.duniter.org/t/gva-graph-verificaton-api-features-wishes/6600):
- Already possible listening on `/ws/blocks`.
- exclusions won’t be loose
- Silkaj would constantly listen to this flow.
- We could also benefit of having direct notifications.
- But, Silkaj will not be able to run into a CI/CD job. It would need to run on a server.
- [x] Request Discourse forum to know if the account exists
- [x] Remove every request and simply prefix all accounts with a `@`:
- This drastically improve the speed and generate much less requests.
- May be the `@` could be extended later on, once the account have been renamed.
- [x] Generate once the message for the two forums/Ğ1
- We might only be keep Monnaie libre forum for Ğ1 exclusions
- [x] Request Cesium+ to get the corresponding name.
- [x] Ignore revoked identities
- [ ] Handle to start the list X days before now (pass an extra parameter).
- [x] Display the reason of the exclusion:
- [x] membership expiration: check membership expiration date
- [x] lack of certifications: check current number of certifications
- [x] Date of the exclusion
### Forums Publication/CLI
- [x] Publish on Discourse forums
- [x] Allow renaming pseudo on the forums
- [x] Add ability to pass a number of hours. One of the days and hours should be present. Both could be present.
- [ ] Ask with a confirmation to publish or not the message if `--publish` option is not passed, Keep `--publish` option.
- [ ] Option(s) to publish on only one of the two forums
- [ ] Stop publishing Ğ1 exclusions on Duniter forum.
#### Discourse API authentication change
- [Discourse API change](https://meta.discourse.org/t/discourse-api-documentation/22706)
- [Header authentication handling in pydiscourse](https://github.com/bennylope/pydiscourse/pull/28)
- Published in `pydiscourse` v1.0.
### Packaging
- [ ] [`pydiscourse`](https://pypi.org/project/pydiscourse/) is not in Debian, this dependency will prevent Silkaj to enter in Debian Bullseye #270:
- [ ] Create DeathReaper package, and set Silkaj as a dependency:
- [x] Create `client/python/deathreaper` git repository/package based on Silkaj: Poetry, CI/CD
- [ ] Introduce a module system in Silkaj:
- Silkaj could install an extra `deathreaper` package:
- The CLI could be extended through Click to add a command, then an `import` should be enough
- [ ] Implement in DuniterPy the used HTTP REST call: `create_post()` to replace `pydiscourse`. Not nice, better let `pydiscourse` project handle the changes of the API. DuniterPy should stay focuse on Ğ1’s APIs.
### Automation
- [x] Executed at 9 AM and PM for Ğ1 and Ğ1-Test with a cron on my machine
- [x] #388: Generate Docker image with Silkaj inside
- [x] [Timezone of the image set to Paris](https://serverfault.com/questions/1012542/docker-container-time-2-hours-behind-when-tz-cest)
- [x] Create `clients/python/deathreaper` repository to set the automation
- Executed at 9 AM and PM for Ğ1 and Ğ1-Test
- Based on the previously generated Docker image
- [x] Pass the API tokens through the CI secret system
- [ ] Could/Should be kept on a machine if all the time running: in case of listening exclusions on a WS
---
## To do later/Improvements
> Open following tickets
- [ ] English translation of the output message?
- [ ] Report joiners (previously excluded) by replying to the post which notifies the exclusion
- …0.10.0MoulMoulhttps://git.duniter.org/clients/python/silkaj/-/issues/351Delete `blockchain verify` command2023-10-21T09:05:15+02:00MoulDelete `blockchain verify` commandOriginal title: tests are sometimes failing due to network outage
https://git.duniter.org/clients/python/silkaj/-/jobs/42791
```
FAILED tests/test_verify_blocks.py::test_get_chunks[2-1] - TypeError: 'NoneTy...
FAILED tests/test_verify_...Original title: tests are sometimes failing due to network outage
https://git.duniter.org/clients/python/silkaj/-/jobs/42791
```
FAILED tests/test_verify_blocks.py::test_get_chunks[2-1] - TypeError: 'NoneTy...
FAILED tests/test_verify_blocks.py::test_get_chunks[5-10] - TypeError: 'NoneT...
```0.12.0MoulMoulhttps://git.duniter.org/clients/python/silkaj/-/issues/47Send documents to many members peers nodes2023-06-02T12:01:39+02:00MoulSend documents to many members peers nodesI sent a transaction yesterday and had a confirmation. But, I couldn't see it on the network.
I may be sent to to `g1.duniter.org:10901` when turned-off for upgrade to v1.2.1.
Silkaj may send its documents to members nodes. At least 1/3...I sent a transaction yesterday and had a confirmation. But, I couldn't see it on the network.
I may be sent to to `g1.duniter.org:10901` when turned-off for upgrade to v1.2.1.
Silkaj may send its documents to members nodes. At least 1/3 of them.Backloghttps://git.duniter.org/clients/python/silkaj/-/issues/53blocks: request chunks of blocks on several nodes2023-06-02T11:59:23+02:00Moulblocks: request chunks of blocks on several nodesNodes blocks requests is limited up to 5.000 blocks.
To handle retrieving all blocks for `blocks` cmd, many requests needs to be done to many nodes.Nodes blocks requests is limited up to 5.000 blocks.
To handle retrieving all blocks for `blocks` cmd, many requests needs to be done to many nodes.Backloghttps://git.duniter.org/clients/python/silkaj/-/issues/3Specifing a local node lead to HTTP error with blocks cmd2022-10-27T18:21:00+02:00Cédric MoreauSpecifing a local node lead to HTTP error with blocks cmdWhen I use the command:
```
./src/silkaj.py issuers 50
```
I successfully get the result:
```
### Issuers for last 50 blocks from block n° 41087 to block n° 41137
| uid | blocks | percent |
|-----------+----------+----------...When I use the command:
```
./src/silkaj.py issuers 50
```
I successfully get the result:
```
### Issuers for last 50 blocks from block n° 41087 to block n° 41137
| uid | blocks | percent |
|-----------+----------+-----------|
| cgeek | 7 | 14.0 |
| moul | 6 | 12.0 |
| nay4 | 6 | 12.0 |
| cler53 | 5 | 10.0 |
| simille | 4 | 8.0 |
| pafzedog | 4 | 8.0 |
| inso | 4 | 8.0 |
| kimamila | 3 | 6.0 |
| gege53 | 2 | 4.0 |
| hacky | 2 | 4.0 |
| Jean-F | 2 | 4.0 |
| charles | 1 | 2.0 |
| gnu-tux | 1 | 2.0 |
| vincentux | 1 | 2.0 |
| modulix | 1 | 2.0 |
| mmpio | 1 | 2.0 |
```
But if select a particular peer which is very close to me (same network) then I get a 503 HTTP error:
```
./src/silkaj.py issuers 50 --peer cgeek.fr:9330
```
```
Traceback (most recent call last):
File "./src/silkaj.py", line 54, in <module>
manage_cmd(ep, c)
File "./src/silkaj.py", line 32, in manage_cmd
list_issuers(ep, int(c.subsubcmd), c.contains_switches('last'))
File "/home/cgeek/dev/silkaj/src/commands.py", line 91, in list_issuers
issuer["pubkey"] = request(ep, "blockchain/block/" + str(blk_nbr))["issuer"]
File "/home/cgeek/dev/silkaj/src/network_tools.py", line 62, in request
response = urllib.request.urlopen(request)
File "/usr/lib/python3.5/urllib/request.py", line 163, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python3.5/urllib/request.py", line 472, in open
response = meth(req, response)
File "/usr/lib/python3.5/urllib/request.py", line 582, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib/python3.5/urllib/request.py", line 510, in error
return self._call_chain(*args)
File "/usr/lib/python3.5/urllib/request.py", line 444, in _call_chain
result = func(*args)
File "/usr/lib/python3.5/urllib/request.py", line 590, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 503: Service Unavailable
```
This is most probably because of Duniter HTTP limiter, which returns an error if a particular URL is called too many times in a second.0.11.0MoulMoulhttps://git.duniter.org/clients/python/silkaj/-/issues/438Add sleep() between identity_of() calls in a loop2022-10-27T18:20:45+02:00MoulAdd sleep() between identity_of() calls in a loop`blocks`, `history --uids`, and `transfer` commands are requesting in a loop `identity_of()` to get `uids` from pubkeys.
There is too much requests at the same time for BMA to answer. Adding a `time.sleep()` in between solves the issue t...`blocks`, `history --uids`, and `transfer` commands are requesting in a loop `identity_of()` to get `uids` from pubkeys.
There is too much requests at the same time for BMA to answer. Adding a `time.sleep()` in between solves the issue to retrieve the `uids` in order for not getting a broken state.
This is specially the case on local node.0.11.0MoulMoulhttps://git.duniter.org/clients/python/silkaj/-/issues/348Create wrapper around client requests to handle DuniterError exception2022-06-28T18:20:54+02:00MoulCreate wrapper around client requests to handle DuniterError exceptionFollowing https://git.duniter.org/clients/python/silkaj/-/merge_requests/143#note_23902
Handle to pass the path argument.
Handle to pass no or variadic extra arguments.Following https://git.duniter.org/clients/python/silkaj/-/merge_requests/143#note_23902
Handle to pass the path argument.
Handle to pass no or variadic extra arguments.https://git.duniter.org/clients/python/silkaj/-/issues/175Migrate from BMA to GVA2022-06-28T18:19:45+02:00MoulMigrate from BMA to GVANew client API implementation GVA with GraphQL:
- [RFC](https://git.duniter.org/nodes/common/doc/merge_requests/3)
- [Forum post](https://forum.duniter.org/t/simplified-verification-api/3631)
- [Forum post about Duniter module](https://f...New client API implementation GVA with GraphQL:
- [RFC](https://git.duniter.org/nodes/common/doc/merge_requests/3)
- [Forum post](https://forum.duniter.org/t/simplified-verification-api/3631)
- [Forum post about Duniter module](https://forum.duniter.org/t/implementation-de-l-api-gva-en-tant-que-module-duniter/5436)
- [DuniterPy ticket](https://git.duniter.org/clients/python/duniterpy/issues/59)
## Plan
- [x] Update to DuniterPy 0.61 which implements GraphQL
- [ ] `duniterpy.api.Client` is used for BMA and GVA. When closing one, it closes the other one. We shouldn't keep both in parallel for now. May be something to search within the singleton to have two separated clients instances.
- [ ] Keep in parallel BMA/GVA? Probably not.
### Network layer
- [x] Use DuniterPy’s `GVAEndpoint`
- [x] Endpoint definition:
- [ ] Use port regex from DuniterPy (redefine it in DuniterPy)
- [x] Add ability to pass and endpoint
- [x] #223, #354: Make optional to have a `click` context
- [x] Handle Gtest
- [x] Use `ipaddress` to separated `host` from `ipv4` which seems not separable from regex matching
- [ ] Rename `-p/--peer` option to `-e/--endpoint`?
### Commands
#### Simple
Replace BMA by GVA in simple commands regarding network requests:
- [ ] `balance`
- [x] #209: One query for multiple balances
- [x] currency string not found in `params` nor `blocks` (`CurrencySymbol()`)
- [x] Merge tables into one table
- [ ] Separation (Textable fonctionnality) between "tables" to improve readability?
- [ ] One query for multiple identities: `identities` query
- [ ] handle pending tx?
- [ ] balance difference between CS/Silkaj calculation <−> GVA?
- [ ] New ticket: display balance of UDs and UTXO from tx (SIG, LOCKED)
- [ ] `argos`
- [ ] `info`
- [ ] `blocks`
#### Complex
Replace BMA by GVA in complex commands with websocket (subscription) and document emission:
- [ ] `diffi`
- [ ] `history`
- [ ] `tx`
- [ ] `id`
- [ ] `wot`
- [ ] `cert`
- [ ] `membership`https://git.duniter.org/clients/python/silkaj/-/issues/229Rewrite 'net' command by a new code using WS2P2022-06-27T18:43:42+02:00MoulRewrite 'net' command by a new code using WS2P- get rid of `net` command in the meanwhile as it is completely broken if bellow implementation is not ready for an next release:
- BMA: `/network/ws2p/heads`
- WS2P: DuniterPy implementation: duniterpy#58, duniterpy!84- get rid of `net` command in the meanwhile as it is completely broken if bellow implementation is not ready for an next release:
- BMA: `/network/ws2p/heads`
- WS2P: DuniterPy implementation: duniterpy#58, duniterpy!84https://git.duniter.org/clients/python/silkaj/-/issues/373Handle synchronous requests from DuniterPy v1.02022-06-27T18:39:53+02:00MoulHandle synchronous requests from DuniterPy v1.0Remove `async/await` keywords.Remove `async/await` keywords.0.10.0MoulMoulhttps://git.duniter.org/clients/python/silkaj/-/issues/397Replace singletons with @functools.lru_cache() decorator2022-04-30T13:52:23+02:00MoulReplace singletons with @functools.lru_cache() decorator- [x] `CurrencySymbol`
- [x] `BlockchainParams`
- [x] `HeadBlock`
- [x] `UDValue`
- [x] `ClientInstance`
---
Use `@functools.lru_cache(maxsize=1)` decorator:
- [Blog article: Simple singletons](https://cosmiccoding.com.au/tutorials/sim...- [x] `CurrencySymbol`
- [x] `BlockchainParams`
- [x] `HeadBlock`
- [x] `UDValue`
- [x] `ClientInstance`
---
Use `@functools.lru_cache(maxsize=1)` decorator:
- [Blog article: Simple singletons](https://cosmiccoding.com.au/tutorials/simple_singletons)
- [Python doc: `functools.lru_cache`](https://docs.python.org/3/library/functools.html#functools.lru_cache)0.11.0MoulMoulhttps://git.duniter.org/clients/python/silkaj/-/issues/216diffi: WebSocket connection get broken2022-03-29T20:06:41+02:00Mouldiffi: WebSocket connection get broken> Follows #93
Time to time, the WebSocket connection get broken, and no new blocks arrive. Then the view stayed frozen. Then a restart is necessary.
It does not happen whether Silkaj and the BMA API (node) is on the same machine.
But...> Follows #93
Time to time, the WebSocket connection get broken, and no new blocks arrive. Then the view stayed frozen. Then a restart is necessary.
It does not happen whether Silkaj and the BMA API (node) is on the same machine.
But with the network in the middle, the connection get broken.
There might be an issue into the websocket wrapper implementation.
[Might be linked to the virtualhost configuration of the http proxy server (Nginx/Apache)](https://forum.duniter.org/t/cesium-nouvelle-version-1-4-17-et-1-5-x-en-test/6706/20?u=moul).0.10.0MoulMoulhttps://git.duniter.org/clients/python/silkaj/-/issues/181Add check for the port when specifying an endpoint2022-03-29T20:03:01+02:00MoulAdd check for the port when specifying an endpointWhen specifying an endpoint with `-p/--peer`, we could mistaken with the domain name.
In that case we will get an error.
But, if we mistake with the port, we don’t get the information that something is wrong.
We should add back this feat...When specifying an endpoint with `-p/--peer`, we could mistaken with the domain name.
In that case we will get an error.
But, if we mistake with the port, we don’t get the information that something is wrong.
We should add back this feature.
Code at 0.6.1 state https://git.duniter.org/clients/python/silkaj/blob/f44bd679f00c95addca7dd827991c8bbaa2b84e4/silkaj/network_tools.py#L190
> #113: 9) "I think the last port is 65535"0.10.0MoulMoulhttps://git.duniter.org/clients/python/silkaj/-/issues/416Move wot_lookup() exceptions handling in higher level functions2022-03-28T19:43:05+02:00matograineMove wot_lookup() exceptions handling in higher level functionswot_lookup() exits on an error (typically an identity not found).
Errors should be managed in higher-level functions to allow specific exit messages.wot_lookup() exits on an error (typically an identity not found).
Errors should be managed in higher-level functions to allow specific exit messages.0.10.0matograinematograinehttps://git.duniter.org/clients/python/silkaj/-/issues/396Drop asynchronous property2022-03-28T19:31:45+02:00MoulDrop asynchronous property- [x] Update to DunitePy v1.0 which removes the asynchronous property, removes `aiohttp` and adds `websocket-client` dependencies
- In runtime and tests environments remove:
- [x] `async`/`await` keywords
- [x] `client.close()` which...- [x] Update to DunitePy v1.0 which removes the asynchronous property, removes `aiohttp` and adds `websocket-client` dependencies
- In runtime and tests environments remove:
- [x] `async`/`await` keywords
- [x] `client.close()` which is now handled by DuniterPy after each request
- Clean other stuff
- [x] Remove `pytest-asyncio` and `asynctest` dev dependencies0.10.0MoulMoulhttps://git.duniter.org/clients/python/silkaj/-/issues/390Implement generic network_tools.send_document()2021-10-03T09:05:26+02:00matograineImplement generic network_tools.send_document()Read this [comment](https://git.duniter.org/clients/python/silkaj/-/merge_requests/170#note_26663).
`network_tools.send_document()` function should take as parameters:
* BMA path where to send the document
* the signed document
It sho...Read this [comment](https://git.duniter.org/clients/python/silkaj/-/merge_requests/170#note_26663).
`network_tools.send_document()` function should take as parameters:
* BMA path where to send the document
* the signed document
It should indicate if the document was sent or not.
Should be first created, then applied to:
- [x] `tx`
- [x] `cert`
- [x] `membership`
- [ ] (`revoke`)
- [ ] (`identity`)0.10.0MoulMoulhttps://git.duniter.org/clients/python/silkaj/-/issues/409Improve endpoint determination code layer2021-08-12T20:45:03+02:00MoulImprove endpoint determination code layerAs part of GVA migration #175, the network layer has been rewritten.
Now, that gva is discontinued, let's apply the network layer improvements to bma.As part of GVA migration #175, the network layer has been rewritten.
Now, that gva is discontinued, let's apply the network layer improvements to bma.0.10.0MoulMoulhttps://git.duniter.org/clients/python/silkaj/-/issues/260Disconnection bug when sending a document to a local node2021-08-08T19:06:25+02:00gerard94Disconnection bug when sending a document to a local nodeÀ la confirmation d'une transaction :
```
gerard@hermes2:~$ silkaj -p 127.0.0.1:57586 -af --file /home/gerard/coffre/G1/Silkaj tx --amountUD 10 --output CxWGA39twcJWkVjqdNWLVy9nVj8CcEPL1yHyJZhjEjSp --comment "tapas 30/11 soir gerard94"
...À la confirmation d'une transaction :
```
gerard@hermes2:~$ silkaj -p 127.0.0.1:57586 -af --file /home/gerard/coffre/G1/Silkaj tx --amountUD 10 --output CxWGA39twcJWkVjqdNWLVy9nVj8CcEPL1yHyJZhjEjSp --comment "tapas 30/11 soir gerard94"
╒════════════════════════════╤══════════════════════════════════════════════╕
│ pubkey’s balance before tx │ 665.35 Ğ1 │
├────────────────────────────┼──────────────────────────────────────────────┤
│ tx amount (unit) │ 101.1 Ğ1 │
├────────────────────────────┼──────────────────────────────────────────────┤
│ tx amount (relative) │ 10.0 UD Ğ1 │
├────────────────────────────┼──────────────────────────────────────────────┤
│ pubkey’s balance after tx │ 564.25 Ğ1 │
├────────────────────────────┼──────────────────────────────────────────────┤
│ from (pubkey) │ 4sfQWXBBy811CCDV6J3YP52EQGK2Ko4x53AAiPa6GGS4 │
├────────────────────────────┼──────────────────────────────────────────────┤
│ to (pubkey) │ CxWGA39twcJWkVjqdNWLVy9nVj8CcEPL1yHyJZhjEjSp │
├────────────────────────────┼──────────────────────────────────────────────┤
│ comment │ tapas 30/11 soir gerard94 │
╘════════════════════════════╧══════════════════════════════════════════════╛
Do you confirm sending this transaction? [yes/no]: yes
Traceback (most recent call last):
File "/home/gerard/.local/bin/silkaj", line 23, in <module>
cli(obj={})
File "/home/gerard/.local/lib/python3.6/site-packages/click/core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "/home/gerard/.local/lib/python3.6/site-packages/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/home/gerard/.local/lib/python3.6/site-packages/click/core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/gerard/.local/lib/python3.6/site-packages/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/gerard/.local/lib/python3.6/site-packages/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/home/gerard/.local/lib/python3.6/site-packages/silkaj/tools.py", line 70, in wrapper
return loop.run_until_complete(f(*args, **kwargs))
File "/usr/lib/python3.6/asyncio/base_events.py", line 484, in run_until_complete
return future.result()
File "/home/gerard/.local/lib/python3.6/site-packages/silkaj/tx.py", line 99, in send_transaction
key, issuer_pubkey, tx_amount, outputAddresses, comment, outputbackchange
File "/home/gerard/.local/lib/python3.6/site-packages/silkaj/tx.py", line 213, in handle_intermediaries_transactions
issuers, AmountTransfered * len(outputAddresses)
File "/home/gerard/.local/lib/python3.6/site-packages/silkaj/tx.py", line 186, in get_list_input_for_transaction
listinput, amount = await get_sources(pubkey)
File "/home/gerard/.local/lib/python3.6/site-packages/silkaj/money.py", line 128, in get_sources
sources = await client(tx.sources, pubkey)
File "/home/gerard/.local/lib/python3.6/site-packages/duniterpy/api/bma/tx.py", line 236, in sources
return await client.get(MODULE + '/sources/%s' % pubkey, schema=SOURCES_SCHEMA)
File "/home/gerard/.local/lib/python3.6/site-packages/duniterpy/api/client.py", line 231, in get
response = await client.requests_get(url_path, **params)
File "/home/gerard/.local/lib/python3.6/site-packages/duniterpy/api/client.py", line 138, in requests_get
timeout=15)
File "/home/gerard/.local/lib/python3.6/site-packages/aiohttp/client.py", line 504, in _request
await resp.start(conn)
File "/home/gerard/.local/lib/python3.6/site-packages/aiohttp/client_reqrep.py", line 847, in start
message, payload = await self._protocol.read() # type: ignore # noqa
File "/home/gerard/.local/lib/python3.6/site-packages/aiohttp/streams.py", line 591, in read
await self._waiter
aiohttp.client_exceptions.ServerDisconnectedError
ERROR:asyncio:Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7f797dd7e4e0>
```0.10.0MoulMoulhttps://git.duniter.org/clients/python/silkaj/-/issues/321Implement the `with` usage on a network client2021-07-29T21:45:30+02:00MoulImplement the `with` usage on a network client> Follow up of #210
That would be great if we could use a connection with the `with` statement as for opening a file.
This would avoid many issues. In particular with tests, and in the code where we have to be handle to close the client...> Follow up of #210
That would be great if we could use a connection with the `with` statement as for opening a file.
This would avoid many issues. In particular with tests, and in the code where we have to be handle to close the client session in every exit edge cases, not to get a stacktrace on properly close a session.
Creating a function out of [`@contextlib.asynccontextmanager`](https://docs.python.org/3/library/contextlib.html#contextlib.asynccontextmanager) would be very nice.
May be this could be introduced in DuniterPy as a helper.
- [StackOverFlow reference](https://stackoverflow.com/a/1522709)https://git.duniter.org/clients/python/silkaj/-/issues/161Singleton improvement2021-07-29T21:40:53+02:00MoulSingleton improvementAs a following of the singleton usage #42, !85, !86, I discover, that it’s not working perfectly. And that, inside the singleton, it was called many time. So, the singleton wasn’t doing was it was made for.
~~Trying to find the issue, I...As a following of the singleton usage #42, !85, !86, I discover, that it’s not working perfectly. And that, inside the singleton, it was called many time. So, the singleton wasn’t doing was it was made for.
~~Trying to find the issue, I discovered [singleton_decorator](https://github.com/Kemaweyan/singleton_decorator) which works fine for the singleton feature.~~
~~Let’s move to this solution.~~
In the end no, because this package won’t be integrated in Distributions such as Debian. So we are going to define a singelton locally from the StackOverFlow link bellow.
---
In the end, I found that we have some issues using asynchronism and singleton.
It feels like async and singleton are not made for and that singleton is not useful with asynchronism.
We get this kind of errors:
`RuntimeWarning: coroutine 'HeadBlock.get_head' was never awaited`
---
Some reading about async singleton:
- https://medium.com/@adambrodziak/singleton-with-async-constructor-in-javascript-32367f52540f
- http://www.laserbrain.se/2015/11/async-singleton-initialization/