Beispiel #1
0
    def __reduce__(self):
        if self._is_started < 0:
            return _coroutine_getmain, ()
        else:
            return type(self), (), self.__dict__


try:
    from threading import local as _local
except ImportError:

    class _local(object):  # assume no threads
        pass


_tls = _local()

# ____________________________________________________________

from collections import deque

import operator
__all__ = 'run getcurrent getmain schedule tasklet channel coroutine'.split()

_global_task_id = 0
_squeue = None
_main_tasklet = None
_main_coroutine = None
_last_task = None
_channel_callback = None
_schedule_callback = None
Beispiel #2
0
            self = getcurrent()
        f = _continulet.__reduce__(self)[2][0]
        if not f:
            return None
        return f.f_back.f_back.f_back   # go past start(), __switch(), switch()

# ____________________________________________________________
# Internal stuff

try:
    from threading import local as _local
except ImportError:
    class _local(object):    # assume no threads
        pass

_tls = _local()

def _green_create_main():
    # create the main greenlet for this thread
    _tls.current = None
    gmain = greenlet.__new__(greenlet)
    gmain._greenlet__main = True
    gmain._greenlet__started = True
    assert gmain.parent is None
    _tls.main = gmain
    _tls.current = gmain

def _greenlet_start(greenlet, args):
    args, kwds = args
    _tls.current = greenlet
    try:
Beispiel #3
0
with TransactionCM('user_import'):
    for login, pwd in source:
        with SavePointCM():
            user = User(username=login)
            user.set_password(pwd)
            user.save()
"""

from uuid import uuid4

from django.db import transaction

from threading import local as _local


_state = _local()

def _reset_state():
    _state.rolled_back = set()
    _state.task_queue = []
    _state.cookies = []
    _state.situation = None

_reset_state()


class AbortTransaction(Exception):
    """
    Исключение, прерывающее текущий CM (SavePointCM/TransactionCM).
    Поймав это исключение CM откатывает изменения,
    произошедшие с момента входа в него и корректно завершается.
Beispiel #4
0
    if config:
        _global_conf_alias.update(config)
    tree.mount(root, script_name, config)
    server.quickstart()
    engine.start()

try:
    from threading import local as _local
except ImportError:
    from cherrypy._cpthreadinglocal import local as _local

# Create a threadlocal object to hold the request, response, and other
# objects. In this way, we can easily dump those objects when we stop/start
# a new HTTP conversation, yet still refer to them as module-level globals
# in a thread-safe way.
_serving = _local()


class _ThreadLocalProxy(object):
    
    __slots__ = ['__attrname__', '_default_child', '__dict__']
    
    def __init__(self, attrname, default):
        self.__attrname__ = attrname
        self._default_child = default
    
    def _get_child(self):
        try:
            return getattr(_serving, self.__attrname__)
        except AttributeError:
            # Bind dummy instances of default objects to help introspection.
"""
Django Tenant Templates
"""
from threading import local as _local


version = '0.5'


local = _local()
local.tenant_slug = None
with TransactionCM('user_import'):
    for login, pwd in source:
        with SavePointCM():
            user = User(username=login)
            user.set_password(pwd)
            user.save()
"""

from uuid import uuid4

from django.db import transaction

from threading import local as _local


_state = _local()


def _reset_state():
    _state.rolled_back = set()
    _state.task_queue = []
    _state.cookies = []
    _state.situation = None


_reset_state()


class AbortTransaction(Exception):
    """
    Исключение, прерывающее текущий CM (SavePointCM/TransactionCM).