osc_process() builtins.AttributeError: 'NoneType' object has no attribute 'wait_for_job'
I have
from osc4py3.as_eventloop import *
from osc4py3 import oscbuildparse
as imports and suddenly osc_process() has started throwing 'NoneType' object has no attribute 'wait_for_job' in the previously all right section of the code:
message = oscbuildparse.OSCMessage('/OSC/*', None, osc_msg)
osc_str = [f': {elem}' for elem in osc_msg]
for index, val in enumerate(osc_str):
data_out.write(osc_str[index])
data_out.write('\n')
osc_send(message, 'OSC_client')
osc_process()
which is executed after osc_msg has been populated with int data in a while loop. Only place I see as a possible cause is the last line of osc_startup() which says write_queue = osctoolspools.WorkQueue(). write_queue = None by default in as_eventloop.py and it should be updated in osc_process():
def osc_process():
# Process packets to be written.
oscdistributing.sendingpackets_process_loop(0, generallogger)
while True:
job = write_queue.wait_for_job(0)
if job is osctoolspools.LAST_JOB or job is None:
break
try:
job()
except:
generallogger.exception("Failure in channel write job")
# Check for data in channels.
if select_monitor:
select_monitor.monitor_oneloop(0)
for mon in pool_monitors:
mon.monitor_oneloop(0)
# Process received data (call functions upon matched addrpatterns).
oscdistributing.rawpackets_process_loop(0, generallogger)
# Process delayed bundles.
oscdispatching.delayed_process_loop(0, generallogger)
Any ideas what might cause this misbehavior? I'm wondering if from osc4py3.as_eventloop import * would be better as import osc4py3.as_eventloop. Does importing * run the variable definitions from the start of the module or does it only import the def objects?
Hello,
The two import methods should be similar (the star import defines names listed in __all__ list of as_eventloop module, and module names are defined when it is imported).
Do you correctly call once osc_startup() at start of program ? This is where write_queue global is defined.
A+ Laurent.