At least for Twisted, that doesn't blend well will stdlib
multiprocessing - and it's not needed anyway.
Simply fork your workers, and each will run a separate event loop.
On Twisted:
https://twistedmatrix.com/documents/current/api/twisted.internet.utils.getProcessOutput.html
with
excutable=sys.executable
args=['myworker.py']
where myworker.py would fire up your component using ApplicationRunner.
Am 16.02.2016 um 11:16 schrieb Oleg Korsak:
> ok, looks like I've found a way to fix that:
>
https://bitbucket.org/snippets/oleg_korsak/5rRGr/revisions/
>
> вторник, 16 февраля 2016 г., 12:10:59 UTC+2 пользователь Oleg Korsak
> написал:
>
> Here is my playground:
>
https://bitbucket.org/snippets/oleg_korsak/5rRGr
> <
https://bitbucket.org/snippets/oleg_korsak/5rRGr>
> While it still spawns multiple processes and they handle requests -
> I get random count of following errors on startup:
> Exception in callback BaseSelectorEventLoop._sock_connect_cb(<Future
> finished result=None>, <socket.socke...6.245', 8090)>,
> ('144.76.226.245', 8090))
> handle: <Handle BaseSelectorEventLoop._sock_connect_cb(<Future
> finished result=None>, <socket.socke...6.245', 8090)>,
> ('144.76.226.245', 8090))>
> Traceback (most recent call last):
> File "/usr/lib64/python3.5/asyncio/events.py", line 125, in _run
> self._callback(*self._args)
> File "/usr/lib64/python3.5/asyncio/selector_events.py", line 443,
> in _sock_connect_cb
> fut.set_result(None)
> File "/usr/lib64/python3.5/asyncio/futures.py", line 329, in
> set_result
> raise InvalidStateError('{}: {!r}'.format(self._state, self))
> asyncio.futures.InvalidStateError: FINISHED: <Future finished
> result=None>
>
> And I'm not sure that asyncio`s event loops are separate and being
> handled correctly in all processes in my case.
> Does this code (
>
http://autobahn.ws/python/_modules/autobahn/asyncio/wamp.html#ApplicationRunner
> <
http://autobahn.ws/python/_modules/autobahn/asyncio/wamp.html#ApplicationRunner>
> ) mean that there is only one global event-loop which fails to be
> used in multiple processes? (I'm weak at asyncio stuff)
>
> понедельник, 15 февраля 2016 г., 16:46:30 UTC+2 пользователь Oleg
> Korsak написал:
>
> Yeah! That's an amazing feature! Thanks! :)
>
> 2016-02-15 12:00 GMT+02:00 Tobias Oberstein
> <
tobias.o...@gmail.com <mailto:
tobias.o...@gmail.com>>:
> <mailto:
tobias.o...@gmail.com
> <mailto:
autobahnws%2Bunsu...@googlegroups.com
> <mailto:
autobahnws%252Buns...@googlegroups.com>>
> <mailto:
autobahnws+...@googlegroups.com
> <mailto:
autobahnws%2Bunsu...@googlegroups.com>
>
> <mailto:
autobahnws%2Bunsu...@googlegroups.com
> <mailto:
autobahnws%252Buns...@googlegroups.com>>>.
> <
https://groups.google.com/d/msgid/autobahnws/9114c821-f788-4546-b515-833c44c212de%40googlegroups.com?utm_medium=email&utm_source=footer
> <
https://groups.google.com/d/optout>.
> <
https://groups.google.com/d/topic/autobahnws/6awZsc8bqXw/unsubscribe>.
> <mailto:
autobahnws%2Bunsu...@googlegroups.com
> <mailto:
autobahnws%252Buns...@googlegroups.com>>.
>
https://groups.google.com/d/msgid/autobahnws/56C19CA0.2010903%40gmail.com
> <
https://groups.google.com/d/msgid/autobahnws/56C19CA0.2010903%40gmail.com>.
> <
https://groups.google.com/d/optout>.
>
https://groups.google.com/d/msgid/autobahnws/CALGa3ynr-caTRcP425-O-x4zVsedThXgXFZWSubhgtdBTmk2eQ%40mail.gmail.com
> <
https://groups.google.com/d/msgid/autobahnws/CALGa3ynr-caTRcP425-O-x4zVsedThXgXFZWSubhgtdBTmk2eQ%40mail.gmail.com>
> <
https://groups.google.com/d/msgid/autobahnws/CALGa3ynr-caTRcP425-O-x4zVsedThXgXFZWSubhgtdBTmk2eQ%40mail.gmail.com?utm_medium=email&utm_source=footer
> <
https://groups.google.com/d/optout>.
> <
https://groups.google.com/d/topic/autobahnws/6awZsc8bqXw/unsubscribe>.
>
https://groups.google.com/d/msgid/autobahnws/56C1A1D5.2020401%40gmail.com
> <
https://groups.google.com/d/msgid/autobahnws/56C1A1D5.2020401%40gmail.com>.
> <
https://groups.google.com/d/optout>.
>
https://groups.google.com/d/msgid/autobahnws/f267e0bd-d723-4119-8203-374e7d5fcc9f%40googlegroups.com
> <
https://groups.google.com/d/msgid/autobahnws/f267e0bd-d723-4119-8203-374e7d5fcc9f%40googlegroups.com?utm_medium=email&utm_source=footer>.