durusmail: quixote-users: Re: Help with using medusa
Help with using medusa
2004-06-18
2004-06-18
2004-06-18
2004-06-18
2004-06-18
2004-06-18
2004-06-18
2004-06-18
2004-06-18
Re: Help with using medusa
2004-06-18
2004-06-18
2004-06-18
2004-06-18
2004-06-19
2004-06-19
2004-06-19
2004-06-19
2004-06-20
Re: Help with using medusa
Vineet Jain
2004-06-18
>
> Note the assert. If, for any reason, the http_server doesn't get
> registered with asyncore's socket map, then asyncore.loop() will exit
> automatically, just as you described. That's why the assert is there:
> to test whether this is the case.
>
>      from medusa import http_server
>      import asyncore
>
>      PORT = 8080
>      server = http_server.http_server('', PORT)
>      assert len(asyncore.socket_map) > 0, 'server not registered!'
>      asyncore.loop()
>
> What happens when you execute it?
>

Gives me the following:

C:\appservers\Quixote-1.0c1\server>test1.py
warning: Computing default hostname
info: Medusa (V1.11) started at Fri Jun 18 16:19:44 2004
        Hostname: vinjvinj
        Port:8080

Traceback (most recent call last):
  File "C:\appservers\Quixote-1.0c1\server\test1.py", line 6, in ?
    assert len(asyncore.socket_map) > 0, 'server not registered!'
AssertionError: server not registered!



> ===========
>
> Here's a slightly more involved example, that includes a running
> execution trace, starting just before the asyncore.loop() call:
>
>      from medusa import http_server
>      import asyncore
>      import inspect
>      import sys
>
>      def trace_func(frame, event, arg):
>          fn, ln, funcname, context, idx = inspect.getframeinfo(frame)
>          fnln = ('%s%s:%s' % (' ' * 25, fn, ln))[-25:]
>          if context is None:
>              print '%s ### %s' % (fnln, event)
>          else:
>              for line in context:
>                  print '%s >>> %s' % (fnln, line.rstrip())
>
>          return trace_func
>
>      PORT = 8080
>      server = http_server.http_server('', PORT)
>      sys.settrace(trace_func)
>      asyncore.loop()
>
>
> And then it pauses, since the select.select() call is waiting for an
> incoming request.
>
> What do you get when you try this second example?

Gives the following:


C:\appservers\Quixote-1.0c1\server>test1.py
warning: Computing default hostname
info: Medusa (V1.11) started at Fri Jun 18 16:22:35 2004
        Hostname: vinjvinj
        Port:8080

hon23\lib\asyncore.py:180 >>> def loop(timeout=30.0, use_poll=0, map=None):
hon23\lib\asyncore.py:181 >>>     if map is None:
hon23\lib\asyncore.py:182 >>>         map = socket_map
hon23\lib\asyncore.py:184 >>>     if use_poll:
hon23\lib\asyncore.py:190 >>>         poll_fun = poll
hon23\lib\asyncore.py:192 >>>     while map:
hon23\lib\asyncore.py:192 >>>     while map:


reply