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


Python EventSocket._connect_cb方法代码示例

本文整理汇总了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) )
开发者ID:agoragames,项目名称:py-eventsocket,代码行数:12,代码来源:evented_socket_test.py

示例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) )
开发者ID:agoragames,项目名称:py-eventsocket,代码行数:12,代码来源:evented_socket_test.py

示例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 )
开发者ID:agoragames,项目名称:py-eventsocket,代码行数:12,代码来源:evented_socket_test.py

示例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 )
开发者ID:agoragames,项目名称:py-eventsocket,代码行数:14,代码来源:evented_socket_test.py

示例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 )
开发者ID:agoragames,项目名称:py-eventsocket,代码行数:15,代码来源:evented_socket_test.py


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