Skip to content
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

Schedulers refactor #37

Merged
merged 7 commits into from
Jul 14, 2017
Merged

Conversation

syrusakbary
Copy link
Owner

@syrusakbary syrusakbary commented Jul 13, 2017

This PR refactors the schedulers so it's easy to plug different instances, and removes the unnecessary abstraction Context.

Also, by default the event loop is deactivated (trampoline is disabled, so the promise resolution go directly to the scheduler).
Available schedulers:

  • promise.schedulers.ImmediateScheduler: executes as soon as is called, good for testing or environments without event loop.
  • promise.schedulers.AsyncioScheduler: scheduler using the asyncio event loop
  • promise.schedulers.GeventScheduler: scheduler using the gevent event loop

How to use a custom scheduler?

from promise import set_default_scheduler
from promise.schedulers.gevent import GeventScheduler

set_default_scheduler(GeventScheduler)

Also, the dataloader will use the default scheduler for loading.

@phil303

Related issue: graphql-python/graphene#488

@syrusakbary syrusakbary force-pushed the features/no-context-and-schedulers-refactor branch from d311e7f to e4fa2e3 Compare July 13, 2017 07:15
@syrusakbary syrusakbary changed the title Features/no context and schedulers refactor Schedulers refactor Jul 13, 2017
Making objects with `.then` method was causing some issues with rx.Observable
@nicwolff
Copy link

nicwolff commented Dec 1, 2023

Is this still the recommended way to use gevent with DataLoader? I can't find any documentation on that, but with the code shown above I get

GeventScheduler.call() missing 1 required positional argument

on all requests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants