當前位置: 首頁>>代碼示例>>Python>>正文


Python eventlet.spawn_after方法代碼示例

本文整理匯總了Python中eventlet.spawn_after方法的典型用法代碼示例。如果您正苦於以下問題:Python eventlet.spawn_after方法的具體用法?Python eventlet.spawn_after怎麽用?Python eventlet.spawn_after使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在eventlet的用法示例。


在下文中一共展示了eventlet.spawn_after方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: spawn_after

# 需要導入模塊: import eventlet [as 別名]
# 或者: from eventlet import spawn_after [as 別名]
def spawn_after(seconds, *args, **kwargs):
        def _launch(func, *args, **kwargs):
            # mimic gevent's default raise_error=False behaviour
            # by not propergating an exception to the joiner.
            try:
                func(*args, **kwargs)
            except greenlet.GreenletExit:
                pass
            except:
                # log uncaught exception.
                # note: this is an intentional divergence from gevent
                # behaviour.  gevent silently ignores such exceptions.
                LOG.error('hub: uncaught exception: %s',
                          traceback.format_exc())

        return eventlet.spawn_after(seconds, _launch, *args, **kwargs) 
開發者ID:OpenState-SDN,項目名稱:ryu,代碼行數:18,代碼來源:hub.py

示例2: init_gui

# 需要導入模塊: import eventlet [as 別名]
# 或者: from eventlet import spawn_after [as 別名]
def init_gui(self):
        # Create the root window
        self.root = tkinter.Tk()
        self.root.geometry('350x75+490+550')
        self.root.title('Hybrid driver')

        # Create a label with status
        self.status = tkinter.StringVar()
        label = tkinter.Label(self.root, width=350, height=75,
                              textvariable=self.status)
        label.pack(fill=tkinter.BOTH, expand=1)

        # Bind key event handlers
        self.root.bind('<Left>', lambda e: self.turn_left())
        self.root.bind('<Right>', lambda e: self.turn_right())
        self.root.bind('<Up>', lambda e: self.speed_up())
        self.root.bind('<Down>', lambda e: self.slow_down())
        self.root.bind('<Key>', self.keydown)

        self.update_status()

        # Start UI loop
        eventlet.spawn_after(1, self.main_loop) 
開發者ID:thomasantony,項目名稱:sdc-live-trainer,代碼行數:25,代碼來源:hybrid_driver.py

示例3: init_gui

# 需要導入模塊: import eventlet [as 別名]
# 或者: from eventlet import spawn_after [as 別名]
def init_gui(self):
        # Create the root window
        self.root = tkinter.Tk()
        self.root.geometry('350x75+490+550')
        self.root.title('Manual driver')

        # Create a label with status
        self.status = tkinter.StringVar()
        label = tkinter.Label(self.root, width=350, height=75,
                              textvariable=self.status)
        label.pack(fill=tkinter.BOTH, expand=1)

        # Bind key event handlers
        self.root.bind('<Left>', lambda e: self.turn_left())
        self.root.bind('<Right>', lambda e: self.turn_right())
        self.root.bind('<Up>', lambda e: self.speed_up())
        self.root.bind('<Down>', lambda e: self.slow_down())
        self.root.bind('<Key>', self.keydown)

        self.update_status()

        # Start UI loop
        eventlet.spawn_after(1, self.main_loop) 
開發者ID:thomasantony,項目名稱:sdc-live-trainer,代碼行數:25,代碼來源:manual_driver.py

示例4: init_gui

# 需要導入模塊: import eventlet [as 別名]
# 或者: from eventlet import spawn_after [as 別名]
def init_gui(self):
        # Create the root window
        self.root = tkinter.Tk()
        self.root.geometry('350x75+490+550')
        self.root.title('SDC Live Trainer')

        # Create a label with status
        self.status = tkinter.StringVar()
        label = tkinter.Label(self.root, width=350, height=75,
                              textvariable=self.status)
        label.pack(fill=tkinter.BOTH, expand=1)

        # Bind key event handlers
        self.root.bind('<Left>', lambda e: self.turn_left())
        self.root.bind('<Right>', lambda e: self.turn_right())
        self.root.bind('<Up>', lambda e: self.speed_up())
        self.root.bind('<Down>', lambda e: self.slow_down())
        self.root.bind('<Key>', self.keydown)

        self.update_status()

        # Start UI loop
        eventlet.spawn_after(1, self.main_loop) 
開發者ID:thomasantony,項目名稱:sdc-live-trainer,代碼行數:25,代碼來源:live_trainer.py

示例5: __init__

# 需要導入模塊: import eventlet [as 別名]
# 或者: from eventlet import spawn_after [as 別名]
def __init__(self, env: GNEnvironment):
        self._lock = Semaphore(value=1)
        self.env = env
        self.to_check = dict()
        self.heartbeat_sids = set()

        self.expire_second = env.config.get(ConfigKeys.TIMEOUT, domain=ConfigKeys.HEARTBEAT, default=300)
        self.sleep_time = env.config.get(ConfigKeys.INTERVAL, domain=ConfigKeys.HEARTBEAT, default=20)

        eventlet.spawn_after(func=self.loop, seconds=10) 
開發者ID:thenetcircle,項目名稱:dino,代碼行數:12,代碼來源:manager.py

示例6: respond_with

# 需要導入模塊: import eventlet [as 別名]
# 或者: from eventlet import spawn_after [as 別名]
def respond_with(gn_event_name=None, should_disconnect=False, emit_response=True):
    def factory(view_func):
        @wraps(view_func)
        def decorator(*args, **kwargs):
            tb = None
            try:
                status_code, data = view_func(*args, **kwargs)
            except Exception as e:
                environ.env.stats.incr(gn_event_name + '.exception')
                tb = traceback.format_exc()
                logger.error('%s: %s' % (gn_event_name, str(e)))
                environ.env.capture_exception(sys.exc_info())

                if should_disconnect and environ.env.config.get(ConfigKeys.DISCONNECT_ON_FAILED_LOGIN, False):
                    eventlet.spawn_after(seconds=1, func=_delayed_disconnect, sid=environ.env.request.sid)
                return 500, str(e)
            finally:
                if tb is not None:
                    logger.exception(tb)

            if status_code != 200:
                logger.warning('in decorator, status_code: %s, data: %s' % (status_code, str(data)))
                if should_disconnect and environ.env.config.get(ConfigKeys.DISCONNECT_ON_FAILED_LOGIN, False):
                    eventlet.spawn_after(seconds=1, func=_delayed_disconnect, sid=environ.env.request.sid)

            # in some cases the callback is enough
            if emit_response:
                response_message = environ.env.response_formatter(status_code, data)
                environ.env.emit(gn_event_name, response_message)

            return status_code, None
        return decorator
    return factory 
開發者ID:thenetcircle,項目名稱:dino,代碼行數:35,代碼來源:decorators.py

示例7: switch_sync_finished

# 需要導入模塊: import eventlet [as 別名]
# 或者: from eventlet import spawn_after [as 別名]
def switch_sync_finished(self):
        if self.do_aging:
            # Give apps a few more seconds to finish their magic
            eventlet.spawn_after(5, self._start_aging)
            LOG.info("Scheduled aged flows deletion") 
開發者ID:openstack,項目名稱:dragonflow,代碼行數:7,代碼來源:aging.py

示例8: _start

# 需要導入模塊: import eventlet [as 別名]
# 或者: from eventlet import spawn_after [as 別名]
def _start(self, first_run_time):
        self._running = True

        now = datetime.utcnow()
        initial_delay = 0 if first_run_time <= now else (
            int(timeutils.delta_seconds(now, first_run_time)))

        self._thread = eventlet.spawn_after(
            initial_delay, self._run, first_run_time)
        self._thread.link(self._on_done) 
開發者ID:openstack,項目名稱:karbor,代碼行數:12,代碼來源:time_trigger.py

示例9: delete_ephemeral_rooms

# 需要導入模塊: import eventlet [as 別名]
# 或者: from eventlet import spawn_after [as 別名]
def delete_ephemeral_rooms(gn_env: GNEnvironment):
    from activitystreams import parse as as_parser

    if len(gn_env.config) == 0 or gn_env.config.get(ConfigKeys.TESTING, False):
        # assume we're testing
        return

    def delete():
        from dino import utils

        channel_dict = gn_env.db.get_channels()

        for channel_id, *_ in channel_dict.items():
            rooms = gn_env.db.rooms_for_channel(channel_id)

            for room_id, room_info in rooms.items():
                short_id = room_id.split('-')[0]
                room_name = room_info['name']
                logger.debug('checking room %s: %s' % (room_id, room_name))

                users = gn_env.db.users_in_room(room_id)
                if len(users) > 0:
                    logger.debug('[%s] NOT removing room (%s), has % user(s) in it' % (short_id, room_name, len(users)))
                    continue

                if not room_info['ephemeral']:
                    logger.debug('[%s] NOT removing room (%s), not ephemeral' % (short_id, room_name))
                    continue

                logger.info('[%s] removing ephemeral room (%s)' % (short_id, room_name))

                try:
                    gn_env.db.get_room_name(room_id)
                except NoSuchRoomException:
                    logger.info('[%s] ephemeral room (%s) has already been removed' % (short_id, room_name))
                    continue

                activity = utils.activity_for_remove_room('0', 'server', room_id, room_name, 'empty ephemeral room')

                gn_env.db.remove_room(channel_id, room_id)

                # no need to notify for wio
                if gn_env.node is not None and 'wio' not in gn_env.node:
                    gn_env.out_of_scope_emit(
                        'gn_room_removed', activity, broadcast=True, include_self=True, namespace='/ws')

                gn_env.observer.emit('on_remove_room', (activity, as_parser(activity)))

    eventlet.spawn_after(seconds=30*60, func=delete) 
開發者ID:thenetcircle,項目名稱:dino,代碼行數:51,代碼來源:environ.py


注:本文中的eventlet.spawn_after方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。