-
Notifications
You must be signed in to change notification settings - Fork 361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Singleton behavior of CurrentThreadScheduler #383
Comments
I have no strong preference either way, and you’re right that removing For the record, though, I only added the |
No, I don't claim that it would restore the 1.x behavior. I claim that removing the
You are probably referring to the factorial example from #358. I think that question is a more general rx question. If I get a cold rx observable (possibly from a third party library), should I be able to locally execute it with |
Ok, sorry, I guess I claim it then :-)
To be honest I don't see how whether or not it has fields come into play, the point of this method was only to enforce the singleton. The subclass problem can be resolved while keeping this method, I'm pretty sure. But I think that would still leave your main issue unaddressed, right? I would really like to see this issue resolved before the imminent v3 release... I'm happy either way, e.g. removing the |
Ok, let's prove then if removing the For RxPY v1.6 I get:
For RxPY v3.0 I get:
And for RxPY v3.0, where the
As you can see, removing the The method I used in RxPY v1.6 to check this is: scheduler1 = CurrentThreadScheduler()
def action1(_, __):
print(scheduler1.queue)
scheduler2 = CurrentThreadScheduler()
def action2(_, __):
print(scheduler2.queue)
scheduler2.schedule(action2)
scheduler1.schedule(action1) And for RxPY v3.0, it is: scheduler1 = CurrentThreadScheduler()
def action1(_, __):
print(scheduler1._local.queue)
scheduler2 = CurrentThreadScheduler()
def action2(_, __):
print(scheduler2._local.queue)
scheduler2.schedule(action2)
scheduler1.schedule(action1) In #363, I did a similar test, which involved more than one thread. |
All right, if you have several schedulers on the same thread, I concede the point. I think that goes slightly against the implied semantics of the scheduler's name, but you are right that's the way it used to be. Sorry, we seem to be going in circles, probably due to my still misunderstanding exactly what changes you would like to see. |
Here is what I've understood about A Also, if I create an instance of So I believe the policy here is that it exists zero or one referenced My point here is if we keep the singleton pattern, we can make a true singleton based on From an rx1.6 end-user perspective, I was really confused about what should I use, So I guess whether the singleton or the 'multi-instanciation' behaviour should be equal and safe for end-users, despite that @MichaelSchneeberger you should run the test suite to check it's not harmful. Also if we remove the singleton and technically allow sub-classing, we should clearly not support it in the issue tracker IMO, because it would be so easy to mess up with |
To resolve this I suggest that we implement things the same way as the Rx.NET CurrentThreadScheduler. They are using a static My suggestion if that we keep and enforce the current singleton behaviour for We should remove the |
this should be fixed in #433 |
From #358 and #363 the following question arises:
CurrentThreadScheduler
have a singleton behavior by default? Or, should the singleton behavior be exposed through a static method like:__new__
method inCurrentThreadScheduler
? I have shown in Don't instantiate new CurrentThreadScheduler._Local with each scheduler instance #363 that theCurrentThreadScheduler
also works without it. Removing it would eliminate the problem of extendingCurrentThreadScheduler
as explained in Enforce CurrentThreadScheduler to run on a dedicated thread? #358.The text was updated successfully, but these errors were encountered: