Comments (4)
Hi @bastienjalbert ,
you are probably after a construct like this:
async def main_loop():
while True:
toto()
tada()
await asyncio.sleep(1) # sleep asynchronously for 1 sec
async def run():
client = CryptoXLib.create_aax_client(api_key, sec_key)
client.compose_subscriptions(...)
await asyncio.gather(*[
client.start_websockets(),
main_loop()
])
await client.close()
if __name__ == "__main__":
async_run(run())
Have a look at examples/ws_subscriptions.py
.
from cryptoxlib-aio.
Thank you @nardew, appreciate that !
Is there any way to prevent main_loop()
to be executed (like waitFor) until the client.start_websockets()
has been "launched" ?
Since toto()
or tada()
may push orders on the market, I would like to monitoring them through the compose_subscriptions
callback, but the websockets subscription / start looks slower then my main_loop()
. I cannot put a While True:
in the main_loop because toto and tada need somehow synchronous. In reality it's only the last step of tada()
who need to do some stuff asynchronously (like checking orders status).
I think I may need multi loop or multi threading to achieve that ...
from cryptoxlib-aio.
I am not quite sure what is the ultimate goal but if you need to make sure toto and tada are called only after the streams are initiated, then you can
i) add toto and tada directly into the websocket callback
ii) have a variable which is set in the websocket callback and then have a check for the variable in the main loop
from cryptoxlib-aio.
Since there was not follow up in the past month, I am closing the thread. Re-open if needed.
from cryptoxlib-aio.
Related Issues (20)
- Fix Onetrading support
- Binanace Spot, Partial Book Depth Streams and others are missed in WS channel HOT 1
- the websocket and REST api for FTX HOT 2
- create_margin_order() returns "code":-1102,"msg":"A mandatory parameter was not sent, was empty/null, or malformed." HOT 2
- Bug on Binance Margin create_margin_order function HOT 3
- Binance Margin (cross/isolated) WS channel has different listen-key HOT 2
- Bitvavo websocket trades, stream has different keyword than subscription HOT 1
- Question: How binance websocket on account channel is keep_alive? HOT 2
- auto reconnection for binance websocket HOT 1
- Binance Private Chnannel listenKeyExpired, auto reconnection HOT 6
- Kraken exchange wrapper HOT 3
- Binance listenkeyExpired in BinanceFuture Websocket Channel HOT 4
- Bugfix on_error()
- test network HOT 2
- Trouble connecting to bitpanda pro HOT 5
- aiohttp==3.7.4 is compatiable with python3.10 HOT 3
- async_create_task is not supported after python3.8 HOT 3
- received 1000 (OK); then sent 1000 (OK) HOT 1
- ModuleNotFoundError: No module named 'cryptoxlib' HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cryptoxlib-aio.