0

I'm having trouble getting clarity on this.

I have a program, say, with three threads - A, B and C.

C is a 'hardware manager', A and B perform their own tasks using APScheduler for scheduling and as part of their routines, make requests of the hardware manager thread.

If I use a time.sleep() in thread C (sometimes necessary to wait on certain hardware-related things to complete), can other methods on thread C be called?

eg. 'A' asks 'C' to turn on a relay which powers a modem. The method incorporates a sleep(), so once it returns, 'A' can expect a network connection to be present. During this time though, 'B' might request a battery voltage reading from an ADC. Should I expect 'B' to be stuck waiting for the first method call to return?

BugSpray
  • 113
  • 9
  • Your question has nothing to do with the GIL. Thread C is sleeping, not executing. You are also mixing threads and objects here; is C a thread or a hardware manager? The latter can use a thread to do work, but the two are not the same thing. – Martijn Pieters Jan 18 '15 at 23:09
  • 1
    As for information about the GIL, see [Does or doesn't Python support multithreading?](http://stackoverflow.com/q/20939299). `time.sleep()` yields to other threads. – Martijn Pieters Jan 18 '15 at 23:10
  • Each one of these objects (A, B and C) is defined as a subclass of threading.Thread - so actually, C is both. – BugSpray Jan 18 '15 at 23:18

1 Answers1

0

OK, so practically speaking, I think the answer is that time.sleep() will yield to other waiting threads.

Perhaps other limitations or concerns will rear their heads in time, but at this stage, performance is not the issue, only concurrency.

BugSpray
  • 113
  • 9