From 317546559197913344f00c3256fcc846d0f7e6d5 Mon Sep 17 00:00:00 2001 From: Erik Kemperman Date: Thu, 2 May 2019 08:49:31 +0200 Subject: [PATCH] Add some notes about CurrentThreadScheduler behaviour --- rx/concurrency/currentthreadscheduler.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/rx/concurrency/currentthreadscheduler.py b/rx/concurrency/currentthreadscheduler.py index 8ad57ee31..6f6596742 100644 --- a/rx/concurrency/currentthreadscheduler.py +++ b/rx/concurrency/currentthreadscheduler.py @@ -35,6 +35,15 @@ class CurrentThreadScheduler(SchedulerBase): """Represents an object that schedules units of work on the current thread. You never want to schedule timeouts using the CurrentThreadScheduler since that will block the current thread while waiting. + + Please note, there will be at most a single instance per thread -- calls to + the constructor will just return the same instance if one already exists. + + Conversely, if you pass an instance to another thread, it will effectively + behave as a separate scheduler, with its own queue. In particular, this + implies that you can't make assumptions about the execution order of items + that were scheduled by different threads -- even if they were submitted to + what superficially appears to be a single scheduler instance. """ class _Local(threading.local): __slots__ = 'idle', 'queue'