python-forexconnect | Python binding of forexconnect api | REST library
kandi X-RAY | python-forexconnect Summary
kandi X-RAY | python-forexconnect Summary
Python binding of forexconnect api
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of python-forexconnect
python-forexconnect Key Features
python-forexconnect Examples and Code Snippets
Community Discussions
Trending Discussions on python-forexconnect
QUESTION
The following code below is simulating a producer and consumer model, which will collect data from a forex broker FXCM and write to a database. Each producer process will have a session based connection with the broker.
Both producer and consumer will run indefinitely until a 'poison pill' is placed into the queue, which happens at the close of business (Friday 22:00). I have omitted this part of the code as it is irrelevant to the problem. All of the examples I can find seem to spawn a process, do some work for a short period and then join()
back to the parent process. Like this one here
As mentioned above the producer will run indefinitely, and the reason for this is because it takes about 3 seconds to log in and create a session with the broker.
When running the code below you will see the Queue backlog, although this seems to be even worst when running the real code.
Not sure if it is relevant but the session is created using the python-forexconnect API, which is written in C++ and uses Boost.
The problem is the consumer is taking too long to get()
items from the queue, and I am wondering if this model is the correct way to approach this type of development.
Thank-you
Sample code
...ANSWER
Answered 2018-Jan-15 at 18:08Horrible performance of multiprocessing.Queue.get()
is a known problem (several questions on Stackoverflow as well, but no answers that would be generally useful).
Which sort of indicates that you should consider another model. You could see how much process creation overhead is compared to this; do not use permanently running processes at all, but launch a process as soon as you have data ready for it. When you do it like this, your subprocess will receive an in-memory copy of data when your process forks. This adds process creation overhead but removes the queue. You could at least consider this as your consumer writes to database and does not need to report anything back to the parent.
Python is a great language but it is not the best performing when it comes to parallel processing.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install python-forexconnect
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page