當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。