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


Python eventsocket.EventSocket类代码示例

本文整理汇总了Python中eventsocket.EventSocket的典型用法代码示例。如果您正苦于以下问题:Python EventSocket类的具体用法?Python EventSocket怎么用?Python EventSocket使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: test_handle_error_no_handler_and_logger_and_no_err_msg

  def test_handle_error_no_handler_and_logger_and_no_err_msg(self):
    sock = EventSocket()
    sock._logger = mock()

    expect(sock._logger.error).args( 'unhandled unknown error', exc_info=True )

    sock._handle_error( 'exception' )
开发者ID:agoragames,项目名称:py-eventsocket,代码行数:7,代码来源:evented_socket_test.py

示例2: test_parent_read_timer_cb_when_read_cb_reset

 def test_parent_read_timer_cb_when_read_cb_reset(self):
   sock = EventSocket()
   sock._pending_read_cb_event = 'foo'
   
   sock._parent_read_timer_cb()
   assert_equals( 'error processing socket input buffer', sock._error_msg )
   assert_equals( None, sock._pending_read_cb_event )
开发者ID:agoragames,项目名称:py-eventsocket,代码行数:7,代码来源:evented_socket_test.py

示例3: test_handle_error_with_handler_and_no_err_msg

  def test_handle_error_with_handler_and_no_err_msg(self):
    sock = EventSocket()
    sock._parent_error_cb = mock()

    expect(sock._parent_error_cb).args( sock, 'unknown error', 'exception' )

    sock._handle_error( 'exception' )
开发者ID:agoragames,项目名称:py-eventsocket,代码行数:7,代码来源:evented_socket_test.py

示例4: test_connect_sets_default_timeout_from_socket

 def test_connect_sets_default_timeout_from_socket(self):
   now = time.time()
   sock = EventSocket()
   expect( time, 'time' ).returns( now )
   sock._sock.settimeout( 8.67 )
   expect( sock._connect_cb ).args( now+8.67, ('localhost',5309), immediate_raise=True )
   sock.connect( ('localhost',5309) )
开发者ID:agoragames,项目名称:py-eventsocket,代码行数:7,代码来源:evented_socket_test.py

示例5: test_handle_error_no_handler_and_no_logger

  def test_handle_error_no_handler_and_no_logger(self):
    sock = EventSocket()
    mock( eventsocket, 'traceback' )

    expect(eventsocket.traceback.print_exc)

    sock._handle_error( 'exception' )
开发者ID:agoragames,项目名称:py-eventsocket,代码行数:7,代码来源:evented_socket_test.py

示例6: test_protected_cb_when_no_error

  def test_protected_cb_when_no_error(self):
    sock = EventSocket()
    cb = mock()

    expect( cb ).args( 'arg1', 'arg2', arg3='foo' ).returns( 'result' )

    assert_equals( 'result', 
      sock._protected_cb( cb, 'arg1', 'arg2', arg3='foo' ) )
开发者ID:agoragames,项目名称:py-eventsocket,代码行数:8,代码来源:evented_socket_test.py

示例7: test_connect_sets_timeoutat_from_kwargs

  def test_connect_sets_timeoutat_from_kwargs(self):
    now = time.time()
    sock = EventSocket()
    expect( time, 'time' ).returns( now )
    expect( sock._connect_cb ).args( now+5.3, ('localhost',5309), immediate_raise=True )
    sock.connect( ('localhost',5309), timeout=5.3 )

    expect( sock._connect_cb ).args( now+5.7, ('localhost',5309), immediate_raise=True )
    sock.connect( ('localhost',5309), timeout_at=now+5.7 )
开发者ID:agoragames,项目名称:py-eventsocket,代码行数:9,代码来源:evented_socket_test.py

示例8: test_set_inactive_timeout_when_turning_off

 def test_set_inactive_timeout_when_turning_off(self):
   sock = EventSocket()
   sock._inactive_event = mock()
   
   expect( sock._inactive_event.delete )
   
   sock.set_inactive_timeout(0)
   assert_equals( None, sock._inactive_event )
   assert_equals( 0, sock._inactive_timeout )
开发者ID:agoragames,项目名称:py-eventsocket,代码行数:9,代码来源:evented_socket_test.py

示例9: test_parent_read_timer_cb

  def test_parent_read_timer_cb(self):
    sock = EventSocket()
    sock._pending_read_cb_event = 'foo'
    sock._parent_read_cb = mock()
    expect( sock._parent_read_cb ).args( sock )

    sock._parent_read_timer_cb()
    assert_equals( 'error processing socket input buffer', sock._error_msg )
    assert_equals( None, sock._pending_read_cb_event )
开发者ID:agoragames,项目名称:py-eventsocket,代码行数:9,代码来源:evented_socket_test.py

示例10: test_connect_cb_when_fail_and_not_immediateraise

  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,代码行数:10,代码来源:evented_socket_test.py

示例11: test_connect_cb_when_ealready_and_timeout

  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,代码行数:10,代码来源:evented_socket_test.py

示例12: test_connect_cb_when_einprogress_and_notimeout_and_no_pending_connect

  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,代码行数:10,代码来源:evented_socket_test.py

示例13: test_flag_activity

  def test_flag_activity(self):
    sock = EventSocket()
    sock._inactive_event = mock()
    sock._inactive_timeout = 42
    
    expect( sock._inactive_event.delete )
    expect( eventsocket.event.timeout ).args( 42, sock._protected_cb, sock._inactive_cb ).returns( 'doitagain' )

    sock._flag_activity()
    assert_equals( 'doitagain', sock._inactive_event )
开发者ID:agoragames,项目名称:py-eventsocket,代码行数:10,代码来源:evented_socket_test.py

示例14: test_write_when_write_event_and_not_pending

  def test_write_when_write_event_and_not_pending(self):
    sock = EventSocket()
    sock._write_event = mock()
    
    expect( sock._write_event.pending ).returns( False )
    expect( sock._write_event.add )
    expect( sock._flag_activity )

    sock.write( 'foo' )
    assert_equals( deque(['foo']), sock._write_buf )
开发者ID:agoragames,项目名称:py-eventsocket,代码行数:10,代码来源:evented_socket_test.py

示例15: test_bind_without_debugging

  def test_bind_without_debugging(self):
    sock = EventSocket()
    sock._sock = mock()
    mock(sock, 'getsockname')
    
    expect(sock._sock.bind).args( 'arg1', 'arg2' )
    expect(sock.getsockname).returns( ('foo',1234) )
    expect(eventsocket.event.read).args( sock, sock._protected_cb, sock._accept_cb )

    sock.bind( 'arg1', 'arg2' )
开发者ID:agoragames,项目名称:py-eventsocket,代码行数:10,代码来源:evented_socket_test.py


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