socket.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:Intranet-Penetration 作者: yuxiaokui 项目源码 文件源码
def wait_write(fileno, timeout=None, timeout_exc=timeout('timed out'), event=None):
    """Block the current greenlet until *fileno* is ready to write.

    If *timeout* is non-negative, then *timeout_exc* is raised after *timeout* second has passed.
    By default *timeout_exc* is ``socket.timeout('timed out')``.

    If :func:`cancel_wait` is called, raise ``socket.error(EBADF, 'File descriptor was closed in another greenlet')``.
    """
    if event is None:
        event = core.write_event(fileno, _wait_helper, timeout, (getcurrent(), timeout_exc))
    else:
        assert event.callback == _wait_helper, event.callback
        assert event.arg is None, 'This event is already used by another greenlet: %r' % (event.arg, )
        event.arg = (getcurrent(), timeout_exc)
        event.add(timeout)
    try:
        switch_result = get_hub().switch()
        assert event is switch_result, 'Invalid switch into wait_write(): %r' % (switch_result, )
    finally:
        event.arg = None
        event.cancel()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号