My code gets events notification and I used to process the events as soon as I get them. Earlier it was single threaded, but the events notification was quite fast to handle them. I changed my code to use multiprocessing using Pool. Here's what I did
- created a
Pool = multiprocessing.pool(processes=4)
(I can process max 11 cores) - add events to the pool for async -
pool.apply_async(go, ["event-1"])
that's all I did. In simple way I'm adding events to the pool and pool will be processed by 4 process's. Now my question is.
- how can I test my events are processed by making use of all 4 process's? I start my scheduler every sunday, Monday is fine, on Tuesday's I still see Monday's events are processed, on Wednesday the number grows many Tuesday events are processed on Wednesday and so on...
I'm basically Java guy, I'm finding difficult to catch how python internally processing my events. I could simply increase the processes but I'm not sure if that helps?
My basic requirement is
- I register myself for events, and would like to process every event
- I would like to process event in separate process so main process/thread still continue listening for new events
- I'm not worried the result of processed event. (but
pool.apply_async(func1,["event1"])
returns values)
Please can you help me fill some thoughts?