本文整理汇总了Python中eventsocket.EventSocket._connect_cb方法的典型用法代码示例。如果您正苦于以下问题:Python EventSocket._connect_cb方法的具体用法?Python EventSocket._connect_cb怎么用?Python EventSocket._connect_cb使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eventsocket.EventSocket
的用法示例。
在下文中一共展示了EventSocket._connect_cb方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_connect_cb_when_fail_and_not_immediateraise
# 需要导入模块: from eventsocket import EventSocket [as 别名]
# 或者: from eventsocket.EventSocket import _connect_cb [as 别名]
def test_connect_cb_when_fail_and_not_immediateraise(self):
sock = EventSocket()
mock( sock, '_sock' )
mock( sock, '_connect_event' )
expect( sock._sock.connect_ex ).args( ('.com', 1234) ).returns( errno.ECONNREFUSED )
expect( sock._connect_event.delete )
expect( sock._handle_error ).args( socket.error )
sock._connect_cb( time.time(), ('.com',1234) )
示例2: test_connect_cb_when_ealready_and_timeout
# 需要导入模块: from eventsocket import EventSocket [as 别名]
# 或者: from eventsocket.EventSocket import _connect_cb [as 别名]
def test_connect_cb_when_ealready_and_timeout(self):
sock = EventSocket()
mock( sock, '_sock' )
mock( sock, '_connect_event' ) # assert delete() not called
timeout_at = time.time()-3
expect( sock._sock.connect_ex ).args( ('.com', 1234) ).returns( errno.EALREADY )
expect( sock.close )
sock._connect_cb( timeout_at, ('.com',1234) )
示例3: test_connect_cb_when_einprogress_and_notimeout_and_no_pending_connect
# 需要导入模块: from eventsocket import EventSocket [as 别名]
# 或者: from eventsocket.EventSocket import _connect_cb [as 别名]
def test_connect_cb_when_einprogress_and_notimeout_and_no_pending_connect(self):
sock = EventSocket()
mock( sock, '_sock' )
timeout_at = time.time()+3
expect( sock._sock.connect_ex ).args( ('.com', 1234) ).returns( errno.EINPROGRESS )
expect( eventsocket.event.timeout ).args( 0.1, sock._connect_cb, timeout_at, ('.com', 1234) ).returns( 'connectev' )
sock._connect_cb( timeout_at, ('.com',1234) )
assert_equals( 'connectev', sock._connect_event )
示例4: test_connect_cb_when_no_err_and_pending_connect_event
# 需要导入模块: from eventsocket import EventSocket [as 别名]
# 或者: from eventsocket.EventSocket import _connect_cb [as 别名]
def test_connect_cb_when_no_err_and_pending_connect_event(self):
sock = EventSocket()
mock( sock, '_sock' )
mock( sock, '_connect_event' )
expect( sock._sock.connect_ex ).args( ('.com', 1234) )
expect( sock._sock.getpeername ).returns( ('.com', 1234) )
expect( eventsocket.event.read ).any_args()
expect( eventsocket.event.write ).any_args()
expect( sock._connect_event.delete )
sock._connect_cb( 3.14, ('.com',1234) )
assert_equals( None, sock._connect_event )
示例5: test_connect_cb_when_no_err
# 需要导入模块: from eventsocket import EventSocket [as 别名]
# 或者: from eventsocket.EventSocket import _connect_cb [as 别名]
def test_connect_cb_when_no_err(self):
sock = EventSocket()
mock( sock, '_sock' )
expect( sock._sock.connect_ex ).args( ('.com', 1234) )
expect( sock._sock.getpeername ).returns( ('.com', 1234) )
expect( eventsocket.event.read ).args( sock._sock, sock._protected_cb, sock._read_cb ).returns( 'readev' )
expect( eventsocket.event.write ).args( sock._sock, sock._protected_cb, sock._write_cb ).returns( 'writeev' )
sock._connect_cb( 3.14, ('.com',1234) )
assert_equals( '.com:1234', sock._peername )
assert_equals( 'readev', sock._read_event )
assert_equals( 'writeev', sock._write_event )
assert_equals( None, sock._connect_event )