File: gevent.rst

package info (click to toggle)
python-gevent 24.11.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 20,364 kB
  • sloc: python: 138,768; ansic: 87,807; sh: 12,548; makefile: 2,379; javascript: 108
file content (123 lines) | stat: -rw-r--r-- 2,621 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
===================================
 :mod:`gevent` -- common functions
===================================

.. module:: gevent

The most common functions and classes are available in the
:mod:`gevent` top level package.

Please read :doc:`/intro` for an introduction to the concepts
discussed here.

.. seealso:: :mod:`gevent.util`

.. seealso:: :doc:`/configuration`

             For configuring gevent using the environment or the
             ``gevent.config`` object.


.. autodata:: __version__


Working With Greenlets
======================

See :class:`gevent.Greenlet` for more information about greenlet
objects.

Creating Greenlets
------------------

.. autofunction:: spawn
.. autofunction:: spawn_later
.. autofunction:: spawn_raw


Getting Greenlets
-----------------

.. function:: getcurrent()

   Return the currently executing greenlet (the one that called this
   function). Note that this may be an instance of :class:`Greenlet`
   or :class:`greenlet.greenlet`.

Stopping Greenlets
------------------

.. autofunction:: kill(greenlet, exception=GreenletExit)

.. autofunction:: killall(greenlets, exception=GreenletExit, block=True, timeout=None)

Sleeping
========

.. autofunction:: sleep

.. autofunction:: idle

Switching
=========

.. function:: getswitchinterval() -> current switch interval


   See :func:`setswitchinterval`

   .. versionadded:: 1.3


.. function:: setswitchinterval(seconds)

   Set the approximate maximum amount of time that callback functions
   will be allowed to run before the event loop is cycled to
   poll for events. This prevents code that does things like the
   following from monopolizing the loop::

       while True: # Burning CPU!
           gevent.sleep(0) # But yield to other greenlets

   Prior to this, this code could prevent the event loop from running.

   On Python 3, this uses the native :func:`sys.setswitchinterval`
   and :func:`sys.getswitchinterval`.

   .. versionadded:: 1.3

Waiting
=======

.. autofunction:: wait

.. autofunction:: iwait

.. autofunction:: joinall

Working with multiple processes
===============================

.. note::
   These functions will only be available if :func:`os.fork` is
   available. In general, prefer to use :func:`gevent.os.fork` instead
   of manually calling these functions.

.. autofunction:: fork

.. autofunction:: reinit

Signals
=======

.. autofunction:: signal_handler

Timeouts
========

See class :class:`gevent.Timeout` for information about Timeout objects.

.. autofunction:: with_timeout

..  LocalWords:  Greenlet GreenletExit Greenlet's greenlet's
..  LocalWords:  automethod