This file is indexed.

/usr/share/pyshared/gevent/rawgreenlet.py is in python-gevent 0.13.6-1ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 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
# Copyright (c) 2009-2010 Denis Bilenko. See LICENSE for details.

"""A few utilities for raw greenlets.

.. warning::

    This module is deprecated. Use :class:`gevent.Greenlet` instead.

.. note::

    These functions do not support *timeout* parameter.
"""

import warnings
warnings.warn("gevent.rawgreenlet is deprecated", DeprecationWarning, stacklevel=2)

import traceback
from gevent import core
from gevent.hub import GreenletExit, Waiter, sleep


__all__ = ['kill',
           'killall',
           'join',
           'joinall']


def _kill(greenlet, exception, waiter):
    try:
        greenlet.throw(exception)
    except:
        traceback.print_exc()
    waiter.switch()


def kill(greenlet, exception=GreenletExit, block=True, polling_period=0.2):
    """Kill greenlet with exception (GreenletExit by default).
    Wait for it to die if block is true.
    """
    if not greenlet.dead:
        waiter = Waiter()
        core.active_event(_kill, greenlet, exception, waiter)
        if block:
            waiter.wait()
            join(greenlet, polling_period=polling_period)


def _killall(greenlets, exception, waiter):
    diehards = []
    for greenlet in greenlets:
        if not greenlet.dead:
            try:
                greenlet.throw(exception)
            except:
                traceback.print_exc()
            if not greenlet.dead:
                diehards.append(greenlet)
    waiter.switch(diehards)


def killall(greenlets, exception=GreenletExit, block=True, polling_period=0.2):
    """Kill all the greenlets with exception (GreenletExit by default).
    Wait for them to die if block is true.
    """
    waiter = Waiter()
    core.active_event(_killall, greenlets, exception, waiter)
    if block:
        alive = waiter.wait()
        if alive:
            joinall(alive, polling_period=polling_period)


def join(greenlet, polling_period=0.2):
    """Wait for a greenlet to finish by polling its status"""
    delay = 0.002
    while not greenlet.dead:
        delay = min(polling_period, delay * 2)
        sleep(delay)


def joinall(greenlets, polling_period=0.2):
    """Wait for the greenlets to finish by polling their status"""
    current = 0
    while current < len(greenlets) and greenlets[current].dead:
        current += 1
    delay = 0.002
    while current < len(greenlets):
        delay = min(polling_period, delay * 2)
        sleep(delay)
        while current < len(greenlets) and greenlets[current].dead:
            current += 1