multiprocessing.Process fetch_trade: 'luno' object has no attribute 'publicGetTickers'
See original GitHub issueHi I’m trying to spawn a process for each of a number of exchanges, and testing with a single one for now, just to get the Multiprocessing working. However, it is failing.
import ccxt
import multiprocessing
if __name__ == '__main__':
exchange_class = getattr(ccxt, 'luno')
exchange = exchange_class()
a_process = multiprocessing.Process(target=exchange.fetch_trades, args=('BTC/ZAR', 1553983200000))
a_process.start()
fails with
AttributeError: 'luno' object has no attribute 'publicGetTickers'
Any way to fix this? If not, any alternatives?
Environment info:
- OS: Win 10, 64 bit
- Programming Language version: Python 3.7.2
- CCXT version: 1.18.398
- Exchange: luno
- Method: fetch_trades(), via multiprocessing.Process()
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:10 (5 by maintainers)
Top Results From Across the Web
yet another confusion with multiprocessing error, 'module ...
The spawn based approach is to either launch a fresh process and import the main module (but not as __main__ , to prevent...
Read more >multiprocessing — Process-based parallelism — Python 3.11 ...
Introduction. multiprocessing is a package that supports spawning processes using an API similar to the threading module. The multiprocessing package offers ...
Read more >multiprocessing Basics - Python Module of the Week - PyMOTW
The simplest way to spawn a second is to instantiate a Process object with a target function and call start() to let it...
Read more >Share Object Instance Attributes With Processes in Python
You can share process class attributes via multiprocessing.Value and multiprocessing.Array instances. In this tutorial you will discover how to ...
Read more >multiprocessing Attribute Error - Esri Community
File "C:\Python26\ArcGIS10.0\lib\multiprocessing\process.py", line 232, ... AttributeError: 'module' object has no attribute'project'.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@ErnstDinkelmann
The above code doesn’t use the rate-limiter, it is off by default and has to be enabled as described in the Manual: https://github.com/ccxt/ccxt/wiki/Manual#rate-limit
If you’re creating one process per exchange, i’d suggest that you rather pass the exchange name to the process, and create the exchange instance inside the worker subprocess:
Does that work for you? (pardon, didn’t have the time to actually test it throughly yet)
Yes, aware of default being false, sorry, just removed that code in the example.
I’m happy with the solution provided.
I guess some further thinking would be required if one wants to fetch trade data with multiple processes, and at the same time execute trades on one or more of the exchanges. I guess this would require rate-limiting to be implemented in the application to be safe.
You are welcome to close this issue. Thank you both.