Skip to content

Strange Behavior in dispatchEventQueue() #46

@Billy10mm

Description

@Billy10mm

dispatchEventQueue() can behave badly if I receive data but don't do anything with it. I'm not sure how else to describe this, but consider the following example code:

from pyrfa import Pyrfa
from threading import Thread
import time

class Reuters(Thread):
    def __init__(self):
        self.rfa = Pyrfa()
        self.running = True
        self.sessions = ['Session1']
        Thread.__init__(self, name='rfa')

    def connect(self):
        self.rfa.createConfigDb('reuters.cfg')
        for session in self.sessions:
            self.rfa.acquireSession(session)
        self.rfa.createOMMConsumer()
        self.rfa.login()
        self.rfa.directoryRequest()
        self.rfa.dictionaryRequest()
        self.subscribe('ESZ8')

    def run(self):
        self.connect()
        while self.running:
            data = self.rfa.dispatchEventQueue(100)

    def subscribe(self, ric):
        self.rfa.marketPriceRequest(ric)

r = Reuters()
r.start()
for x in range(0,5):
    print '{:.6f}'.format(time.time())
    time.sleep(1)
r.running = False

When I run the above on Python 2.7.15 (with optimizations enabled), the process hangs seemingly forever (it eventually does end, but it can take over 20 minutes). But if you simply add a print data immediately following the call to dispatchEventQueue(), then the software does not hang and ends in approximately 5 seconds as it should. If I change the call to dispatchEventQueue() and remove the blocking timeout as so, data = self.rfa.dispatchEventQueue(), then I have no issues at all.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions