Closed paddymccrudden closed 5 years ago
Why do you need this, what are you trying to do?
I am building a system for financial modelling. The objects include typical financial entities such as portfolios, accounts, orders, executions, order management systems, exchanges etc. An event-based program architecture works well for this. However, there are (at least) two levels at which the messages are appropriate. For example, there are "public" messages that are shared between entities such as Portfolios and Exchanges, and there are "private" messages that occur within those entities.
I believe it would be reasonable to simply have a base topic such as "public" for the general messages, and another topic for within the entities. However, with a view to multi-threading, and distributed calculations, it would seem more natural to have multiple Publish() objects.
(Thanks for the speedy response!)
Thanks for the additional info. Plaease clarify:
Thanks for you prompt response.
I am comfortable right now with one message queue for my application, and so you may close this issue. Thanks again!
I might just add one more comment. When running unit test, the pub module is imported, and the pub object persists between tests when using pytest. This means that if you modify the topics, for example, in one test, then those modifications will persist into the next test. This makes it quite challenging to have effective unit tests. I would argue that this is a problem with pytest, not pubsub having only one import, but creating new pub objects would be a way to avoid this problem.
Excellent, glad to hear that!
Hi @schollii. I'm pleased to report that my program works well with pypubsub, and it is very convinient. However, in order to implement my machine learning algorithm with Hogwild! (https://github.com/pytorch/examples/tree/master/mnist_hogwild) I need to run it in a multi-thread environment so that I can run in parallel. This re-opens the multiple publisher issue for me. Again - any thoughts on creating a new publisher for each thread?
There are many different aspects to this, probably easier to do in a chat forum like gitter. Let me know if you would like to discuss.
I did not mean to close this yet :/
In any case the main considerations are:
assert threading.current_thread() is assign_thread
where assigned_thread is something you define at beginning of your app runNote that "assigned thread" is a design construct; python does not assign functions to threads, it's up to you to determine whether some functions always run in same thread etc.
Feel free to re-open.
As noted at pubsub.readthedocs, the expression
As noted in this quote, the pub module does quite at bit of work to expose methods and attributes, and it is not immediately obvious how to build a new Publisher() object with the correct attributes exposed. I'd be really interested in knowing if there is a standard way to do this. Alternatively, perhaps we could add a new module that provides this.