当前位置: 首页>>代码示例>>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;未经允许,请勿转载。