当前位置: 首页>>代码示例>>Python>>正文


Python gevent.kill方法代码示例

本文整理汇总了Python中gevent.kill方法的典型用法代码示例。如果您正苦于以下问题:Python gevent.kill方法的具体用法?Python gevent.kill怎么用?Python gevent.kill使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gevent的用法示例。


在下文中一共展示了gevent.kill方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: detach

# 需要导入模块: import gevent [as 别名]
# 或者: from gevent import kill [as 别名]
def detach(self):
        if self._has_destroy:
            return
        super().detach()
        if self._auto_disconnect_greenlet:
            gevent.kill(self._auto_disconnect_greenlet)
            self._auto_disconnect_greenlet = None

        if self.videocall_user:
            self._plugin.user_dao.del_by_username(self.videocall_user.username)
            self.videocall_user.handle = None
            self.videocall_user = None

        if self.backend_handle:
            backend_handle = self.backend_handle
            self.backend_handle = None
            backend_handle.detach() 
开发者ID:OpenSight,项目名称:janus-cloud,代码行数:19,代码来源:videocall.py

示例2: on_close

# 需要导入模块: import gevent [as 别名]
# 或者: from gevent import kill [as 别名]
def on_close(self, handle_id):
        self.backend_handle = None #detach with backend handle

        if self._auto_disconnect_greenlet:
            gevent.kill(self._auto_disconnect_greenlet)
            self._auto_disconnect_greenlet = None

        if self.videocall_user and self.videocall_user.incall:
            self.videocall_user.peer_name = ''
            self.videocall_user.incall = False
            self.videocall_user.utime = time.time()
            self._plugin.user_dao.update(self.videocall_user.peer_name)

            hangup_event_data = {
                'videocall': 'event',
                'result' : {
                    "event" : "hangup",
                    "username" : self.videocall_user.username,
                    "reason" : "backend handle closed"
                }
            }
            self._push_plugin_event(hangup_event_data, None, None) 
开发者ID:OpenSight,项目名称:janus-cloud,代码行数:24,代码来源:videocall.py

示例3: destroy

# 需要导入模块: import gevent [as 别名]
# 或者: from gevent import kill [as 别名]
def destroy(self):
        if self.state == BACKEND_SESSION_STATE_DESTROYED:
            return
        self.state = BACKEND_SESSION_STATE_DESTROYED
        if _sessions.get(self.url) == self:
            _sessions.pop(self.url)

        if self._auto_destroy_greenlet:
            gevent.kill(self._auto_destroy_greenlet)
            self._auto_destroy_greenlet = None

        for handle in self._handles.values():
            handle.on_close()
        self._handles.clear()

        if self._ws_client:
            try:
                self._ws_client.close()
            except Exception:
                pass
            self._ws_client = None 
开发者ID:OpenSight,项目名称:janus-cloud,代码行数:23,代码来源:backend_session.py

示例4: _run

# 需要导入模块: import gevent [as 别名]
# 或者: from gevent import kill [as 别名]
def _run(self):
        # Bind greenlet-local logging context.
        self.log = log.new(account_id=self.account_id, folder=self.folder_name,
                           provider=self.provider_name)
        # eagerly signal the sync status
        self.heartbeat_status.publish()

        try:
            self.update_folder_sync_status(lambda s: s.start_sync())
        except IntegrityError:
            # The state insert failed because the folder ID ForeignKey
            # was no longer valid, ie. the folder for this engine was deleted
            # while we were starting up.
            # Exit the sync and let the monitor sort things out.
            log.info("Folder state loading failed due to IntegrityError",
                     folder_id=self.folder_id, account_id=self.account_id)
            raise MailsyncDone()

        # NOTE: The parent ImapSyncMonitor handler could kill us at any
        # time if it receives a shutdown command. The shutdown command is
        # equivalent to ctrl-c.
        while True:
            retry_with_logging(self._run_impl, account_id=self.account_id,
                               provider=self.provider_name, logger=log) 
开发者ID:nylas,项目名称:sync-engine,代码行数:26,代码来源:generic.py

示例5: attach_handle

# 需要导入模块: import gevent [as 别名]
# 或者: from gevent import kill [as 别名]
def attach_handle(self, plugin_package_name, opaque_id=None, handle_listener=None):
        """

        :param plugin_pacakge_name:  str plugin package name
        :param opaque_id:   str opaque id
        :param handle_listener: handle related  callback listener which cannot block
        :return: BackendHandle object
        """
        if self.state == BACKEND_SESSION_STATE_DESTROYED:
            raise JanusCloudError('Session has destroy for Janus server: {}'.format(self.url),
                                  JANUS_ERROR_SERVICE_UNAVAILABLE)

        attach_request_msg = create_janus_msg('attach', plugin=plugin_package_name)
        if opaque_id:
            attach_request_msg['opaque_id'] = opaque_id

        response = self.send_request(attach_request_msg)  # would block for IO
        if response['janus'] == 'success':
             handle_id = response['data']['id']
        elif response['janus'] == 'error':
            raise JanusCloudError(
                'attach error for Janus server {} with reason {}'.format(self.url, response['error']['reason']),
                response['error']['code'])
        else:
            raise JanusCloudError(
                'attach error for Janus server: {} with invalid response {}'.format(self.url, response),
                JANUS_ERROR_BAD_GATEWAY)

        # check again when wake up from block IO
        if self.state == BACKEND_SESSION_STATE_DESTROYED:
            raise JanusCloudError('Session has destroy for Janus server: {}'.format(self.url),
                                  JANUS_ERROR_SERVICE_UNAVAILABLE)

        handle = BackendHandle(handle_id, plugin_package_name, self,
                               opaque_id=opaque_id, handle_listener=handle_listener)
        self._handles[handle_id] = handle
        if self._auto_destroy_greenlet:
            gevent.kill(self._auto_destroy_greenlet)
            self._auto_destroy_greenlet = None
        return handle 
开发者ID:OpenSight,项目名称:janus-cloud,代码行数:42,代码来源:backend_session.py

示例6: gevent_stop

# 需要导入模块: import gevent [as 别名]
# 或者: from gevent import kill [as 别名]
def gevent_stop(self):
        """
        Helper method to stop the node for gevent-based applications.
        """
        import gevent
        gevent.kill(self._poller_greenlet)
        self.remove()
        self._select = select.select 
开发者ID:closeio,项目名称:redis-hashring,代码行数:10,代码来源:__init__.py

示例7: _watch_progress

# 需要导入模块: import gevent [as 别名]
# 或者: from gevent import kill [as 别名]
def _watch_progress(handler):
    """Context manager for creating a unix-domain socket and listen for
    ffmpeg progress events.

    The socket filename is yielded from the context manager and the
    socket is closed when the context manager is exited.

    Args:
        handler: a function to be called when progress events are
            received; receives a ``key`` argument and ``value``
            argument. (The example ``show_progress`` below uses tqdm)

    Yields:
        socket_filename: the name of the socket file.
    """
    with _tmpdir_scope() as tmpdir:
        socket_filename = os.path.join(tmpdir, 'sock')
        sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
        with contextlib.closing(sock):
            sock.bind(socket_filename)
            sock.listen(1)
            child = gevent.spawn(_do_watch_progress, socket_filename, sock, handler)
            try:
                yield socket_filename
            except:
                gevent.kill(child)
                raise 
开发者ID:kkroening,项目名称:ffmpeg-python,代码行数:29,代码来源:show_progress.py

示例8: terminate

# 需要导入模块: import gevent [as 别名]
# 或者: from gevent import kill [as 别名]
def terminate():
    """Terminate all greenlets.
    """
    gevent.kill(produce_danmaku)
    gevent.kill(consume_danmaku)
    gevent.kill(heartbeat) 
开发者ID:OctavianLee,项目名称:Barrage,代码行数:8,代码来源:produce_and_consume.py

示例9: exit

# 需要导入模块: import gevent [as 别名]
# 或者: from gevent import kill [as 别名]
def exit(self, signal=None):
        """ Handle an exit request """
        self.logger.info("{} {}".format(signal, "*" * 80))
        # Kill the top level greenlet
        gevent.kill(gevent.hub.get_hub().parent) 
开发者ID:simplecrypto,项目名称:powerpool,代码行数:7,代码来源:main.py

示例10: destroy

# 需要导入模块: import gevent [as 别名]
# 或者: from gevent import kill [as 别名]
def destroy(self):
        if self.connected:
            log.debug("Disconnecting")
            self.role.stack.disconnect()
            self.role = None

        if self.socket_handler is not None:
            log.debug("Connection quit(), killing remaining connection threads")
            gevent.kill(self.socket_handler_thread)
            self.socket_handler = None
            self.socket_handler_thread = None

        if self.event_handler is not None:
            self.event_handler.__del__()
            self.event_handler = None 
开发者ID:nccgroup,项目名称:BLESuite,代码行数:17,代码来源:core.py

示例11: on_open

# 需要导入模块: import gevent [as 别名]
# 或者: from gevent import kill [as 别名]
def on_open(self):
        if self.ws.protocol is None or (
                GRAPHQL_SUBSCRIPTIONS not in self.ws.protocol):
            self.ws.close(1002)

        def keep_alive_callback():
            if not self.ws.closed:
                self.send_keep_alive()
            else:
                gevent.kill(keep_alive_timer)

        if self.keep_alive:
            keep_alive_timer = gevent.spawn(self.timer, keep_alive_callback,
                                            self.keep_alive) 
开发者ID:hballard,项目名称:graphql-python-subscriptions,代码行数:16,代码来源:subscription_transport_ws.py

示例12: async_raise_in_main_thread

# 需要导入模块: import gevent [as 别名]
# 或者: from gevent import kill [as 别名]
def async_raise_in_main_thread(exc, use_concurrent_loop=True):
    """
    Uses a unix signal to raise an exception to be raised in the main thread.
    """

    from plumbum import local
    pid = os.getpid()
    if not REGISTERED_SIGNAL:
        raise NotInitialized()

    # sometimes the signal isn't caught by the main-thread, so we should try a few times (WEKAPP-14543)
    def do_signal(raised_exc):
        global LAST_ERROR
        if LAST_ERROR is not raised_exc:
            _logger.debug("MainThread took the exception - we're done here")
            if use_concurrent_loop:
                raiser.stop()
            return

        _logger.info("Raising %s in main thread", type(LAST_ERROR))
        local.cmd.kill("-%d" % REGISTERED_SIGNAL, pid)

    if use_concurrent_loop:
        from .concurrency import concurrent
        raiser = concurrent(do_signal, raised_exc=exc, loop=True, sleep=30, daemon=True, throw=False)
        raiser.start()
    else:
        do_signal(exc) 
开发者ID:weka-io,项目名称:easypy,代码行数:30,代码来源:sync.py

示例13: _rimt

# 需要导入模块: import gevent [as 别名]
# 或者: from gevent import kill [as 别名]
def _rimt(exc):
        _logger.info('YELLOW<<killing main thread greenlet>>')
        main_thread_greenlet = threading.main_thread()._greenlet
        orig_throw = main_thread_greenlet.throw

        # we must override "throw" method so exception will be raised with the original traceback
        def throw(*args):
            if len(args) == 1:
                ex = args[0]
                return orig_throw(ex.__class__, ex, ex.__traceback__)
            return orig_throw(*args)
        main_thread_greenlet.throw = throw
        gevent.kill(main_thread_greenlet, exc)
        _logger.debug('exiting the thread that failed')
        raise exc 
开发者ID:weka-io,项目名称:easypy,代码行数:17,代码来源:sync.py

示例14: kill_this_process

# 需要导入模块: import gevent [as 别名]
# 或者: from gevent import kill [as 别名]
def kill_this_process(graceful=False):
    from plumbum import local
    pid = os.getpid()
    if graceful:
        flag = '-HUP'
    else:
        flag = '-9'
    local.cmd.kill(flag, pid) 
开发者ID:weka-io,项目名称:easypy,代码行数:10,代码来源:sync.py

示例15: startWeb

# 需要导入模块: import gevent [as 别名]
# 或者: from gevent import kill [as 别名]
def startWeb(p,resourcePath,nonesym,timec,timebg,btc,btbg,etc,etbg,showetflag,showbtflag):
    global port, process, static_path, nonesymbol, timecolor, timebackground, btcolor, btbackground, etcolor, etbackground, showet, showbt
    port = p
    static_path = resourcePath
    nonesymbol = nonesym
    timecolor = timec
    timebackground = timebg
    btcolor = btc
    btbackground = btbg
    etcolor = etc
    etbackground = etbg
    showet = showetflag
    showbt = showbtflag
    if psystem() != 'Windows':
        gsignal(SIGQUIT, kill)

    process = mp.Process(name='WebLCDs',target=work,args=(
        port,
        resourcePath,
        nonesym,
        timec,
        timebg,
        btc,
        btbg,
        etc,
        etbg,
        showetflag,
        showbtflag,))
    process.start()
    
    libtime.sleep(4)
    
    if process.is_alive():    
        # check successful start
        url = "http://127.0.0.1:" + str(port) + "/status"
        r = rget(url,timeout=2)
        
        if r.status_code == 200:
            return True
        else:
            return False
    else:
        return False 
开发者ID:artisan-roaster-scope,项目名称:artisan,代码行数:45,代码来源:weblcds.py


注:本文中的gevent.kill方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。