I solved the issue by using threading.Event
and keeping the client in the main thread:
import threading
from apscheduler.scheduler import Scheduler
import logging
# Start the scheduler
logging.basicConfig()
sched = Scheduler()
sched.start()
ev = threading.Event()
# Schedule job_function
sched.add_interval_job(job, Ts, args=[ev])
while True:
ev.wait()
# do stuff with the unmarshallable object
ev.clear()
def job(ev):
ev.set()
I haven't noticed time drifts with this approach.