syrusakbary / promise

Ultra-performant Promise implementation in Python
MIT License
362 stars 76 forks source link

Schedulers refactor #37

Closed syrusakbary closed 7 years ago

syrusakbary commented 7 years ago

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:

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: https://github.com/graphql-python/graphene/issues/488

nicwolff commented 12 months ago

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.