[zeromq-dev] Newbie question about Router/Dealer

Mazzaroth M. taomailings at gmail.com
Fri Jul 1 23:40:22 CEST 2016


I have a publisher.py that listens for tweets. When a tweet happens, I
submit a job to the Router(just a simple number for now). In the Router I
have a self._work Python List that is inited in __init__. When I do a
router.submit(job) and extend the _work List with a Job, it doesn't appear
in the List in a separate while loop. The self._work list is empty and
stays that way. Any ideas why the instance variable is unmodified?

publisher:

        if len(send_dict.keys()) > 0:
            LOG.info('send_dict: {0}'.format(repr(send_dict)))
            job = Job({'number': 11})
            LOG.info('g_router: %s job: %s', repr(g_router), repr(job))
            g_router.submit_job(job)

router:

    def submit_job(self, job):
        self._work.extend(job)
        LOG.info('submit_job self._work: %s', repr(self._work))


    def run(self):
        LOG.info('CLASS run router %s _work: %s', repr(self.context),
repr(self._work))
        while True:
            next_worker_id = None
            LOG.info('submit_job self._work: %s', repr(self._work))
            job = None
            if self._work:
                job = self._work.pop()
            if job:

                while next_worker_id is None:
                    # First check if there are any worker messages to
process. We
                    # do this while checking for the next available worker
so that
                    # if it takes a while to find one we're still processing
                    # incoming messages.
                    while self.socket.poll(0):
  .. and so on ..

log:

2016-07-01 17:29:02,488 INFO  [main.router][MainThread] *submit_job
self._work: []*

why is the list empty? There a more elegant way to process work/jobs like
this?

code:

publisher http://pastebin.com/Exn86M7M
router http://pastebin.com/cbfn1M9d
worker http://pastebin.com/BDXBbLGi

log http://pastebin.com/SH7UUrdD

regards,
Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20160701/58349598/attachment.html>


More information about the zeromq-dev mailing list