gevent.events
– Publish/subscribe event infrastructure¶Publish/subscribe event infrastructure.
When certain “interesting” things happen during the lifetime of the process, gevent will “publish” an event (an object). That event is delivered to interested “subscribers” (functions that take one parameter, the event object).
Higher level frameworks may take this foundation and build richer models on it.
zope.event
will be used to provide the functionality of
notify
and subscribers
. See zope.event.classhandler
for a
simple class-based approach to subscribing to a filtered list of
events, and see zope.component for a
much higher-level, flexible system. If you are using one of these
systems, you generally will not want to directly modify subscribers
.
New in version 1.3b1.
Bases: BaseException
Subscribers to will-patch events can raise instances of this class to tell gevent not to patch that particular item.
The event emitted when the event loop is blocked.
This event is emitted in the monitor thread.
The greenlet that appeared to be blocking the loop.
The approximate time in seconds the loop has been blocked.
A sequence of string lines providing extra info.
Extends: gevent.events.IGeventDidPatchEvent
Event emitted after gevent has patched all modules, both builtin and those provided by plugins/subscribers.
The values of the source and target attributes are undefined.
Extends: gevent.events.IGeventDidPatchEvent
Event emitted after the builtin modules have been patched.
If you’re going to monkey-patch a third-party library, this is usually the event to listen for.
The values of the source and target attributes are undefined.
A dictionary of all the arguments to gevent.monkey.patch_all
. This dictionary should not be modified.
A dictionary of the extra arguments to gevent.monkey.patch_all
. This dictionary should not be modified.
Extends: gevent.events.IGeventPatchEvent
An event emitted after gevent has patched something.
Extends: gevent.events.IGeventDidPatchEvent
An event emitted after gevent has completed patching a specific module.
The name of the module being patched. This is the same as target.__name__
.
The root for all monkey-patch events gevent emits.
The source object containing the patches.
The destination object to be patched.
Extends: gevent.events.IGeventWillPatchEvent
An event emitted before gevent begins patching the system.
Following this event will be a series of
IGeventWillPatchModuleEvent
and IGeventDidPatchModuleEvent
for
each patched module.
Once the gevent builtin modules have been processed,
IGeventDidPatchBuiltinModulesEvent
will be emitted. Processing
this event is an ideal time for third-party modules to be imported
and patched (which may trigger its own will/did patch module
events).
Finally, a IGeventDidPatchAllEvent
will be sent.
If a subscriber to this event raises DoNotPatch
, no patching
will be done.
The source and target attributes have undefined values.
A dictionary of all the arguments to gevent.monkey.patch_all
. This dictionary should not be modified.
A dictionary of the extra arguments to gevent.monkey.patch_all
. This dictionary should not be modified.
Return whether the module named module_name will be patched.
Extends: gevent.events.IGeventPatchEvent
An event emitted before gevent monkey-patches something.
If a subscriber raises DoNotPatch
, then patching this particular
item will not take place.
Extends: gevent.events.IGeventWillPatchEvent
An event emitted before gevent begins patching a specific module.
Both source and target attributes are module objects.
The name of the module being patched. This is the same as target.__name__
.
The list of item names to patch. This can be modified in place with caution.
The event emitted when the memory usage threshold is exceeded.
This event is emitted only while memory continues to grow above the threshold. Only if the condition or stabilized is corrected (memory usage drops) will the event be emitted in the future.
This event is emitted in the monitor thread.
The current process memory usage, in bytes.
The maximum allowed memory usage, in bytes.
The tuple of memory usage stats return by psutil.
The event emitted when the memory usage drops below the threshold after having previously been above it.
This event is emitted only the first time memory usage is detected
to be below the threshold after having previously been above it.
If memory usage climbs again, a IMemoryUsageThresholdExceeded
event will be broadcast, and then this event could be broadcast again.
This event is emitted in the monitor thread.
The current process memory usage, in bytes.
The maximum allowed memory usage, in bytes.
The memory usage that caused the previous IMemoryUsageThresholdExceeded event.
The tuple of memory usage stats return by psutil.
The contract for the periodic monitoring thread that is started by the hub.
Schedule the function to be called approximately every period fractional seconds.
The function receives one argument, the hub being monitored. It is called in the monitoring thread, not the hub thread. It must not attempt to use the gevent asynchronous API.
If the function is already a monitoring function, then its period will be updated for future runs.
If the period is None
, then the function will be removed.
A period less than or equal to zero is not allowed.
The event emitted when a hub starts a periodic monitoring thread.
You can use this event to add additional monitoring functions.
The instance of IPeriodicMonitorThread
that was started.
Bases: object
The event emitted when the event loop is blocked.
Implements IEventLoopBlocked
.
Bases: _PatchAllMixin
, GeventDidPatchEvent
Implementation of IGeventDidPatchAllEvent
.
The name of the setuptools entry point that is called when this event is emitted.
Bases: _PatchAllMixin
, GeventDidPatchEvent
Implementation of IGeventDidPatchBuiltinModulesEvent
.
The name of the setuptools entry point that is called when this event is emitted.
Bases: GeventDidPatchEvent
Implementation of IGeventDidPatchModuleEvent
.
The name of the setuptools entry point that is called when this event is emitted.
Bases: object
Implementation of IGeventPatchEvent
.
Bases: _PatchAllMixin
, GeventWillPatchEvent
Implementation of IGeventWillPatchAllEvent
.
The name of the setuptools entry point that is called when this event is emitted.
Bases: GeventPatchEvent
Implementation of IGeventWillPatchEvent
.
Bases: GeventWillPatchEvent
Implementation of IGeventWillPatchModuleEvent
.
The name of the setuptools entry point that is called when this event is emitted.
Bases: _AbstractMemoryEvent
Implementation of IMemoryUsageThresholdExceeded
.
Bases: _AbstractMemoryEvent
Implementation of IMemoryUsageUnderThreshold
.
Bases: object
The implementation of IPeriodicMonitorThreadStartedEvent
.
The name of the setuptools entry point that is called when this event is emitted.
Applications may register for notification of events by appending a
callable to the subscribers
list.
Each subscriber takes a single argument, which is the event object being published.
Exceptions raised by subscribers will be propagated without running any remaining subscribers.
This is an alias for zope.event.subscribers
; prefer to use
that attribute directly.
Next page: gevent.exceptions
– Exceptions