Remove start_rpc_server() and make Rpc a context manager

Rpc now has a start() method.
This way it is possible to use Rpc from IPython without calling __aenter__()
This commit is contained in:
link2xt
2022-12-04 00:02:32 +00:00
parent 5a3065344e
commit 2ccf39800d
5 changed files with 38 additions and 36 deletions

View File

@@ -30,11 +30,12 @@ from the REPL.
$ pip install ipython
$ PATH="../target/debug:$PATH" ipython
...
In [1]: from deltachat_rpc_client import *
In [2]: rpc_generator = start_rpc_server()
In [3]: rpc = await rpc_generator.__aenter__()
In [4]: dc = Deltachat(rpc)
In [5]: system_info = await dc.get_system_info()
In [6]: system_info["level"]
Out [6]: 'awesome'
In [1]: from deltachat_rpc_client import *
In [2]: rpc = Rpc()
In [3]: await rpc.start()
In [4]: dc = Deltachat(rpc)
In [5]: system_info = await dc.get_system_info()
In [6]: system_info["level"]
Out[6]: 'awesome'
In [7]: await rpc.close()
```