Vineet Jain wrote: > It starts and then shuts down. I put print statements before and after the: > > print 'starting async loop' > asyncore.loop() > print 'finished async loop' [snip] > What should I try I next. I searched on the internet and did not get much > success on medusa. It looks like a problem with asyncore, not particularly with Medusa. Perhaps you might have better luck searching for "asyncore loop problems"? Let's eliminate some possibilities... =========== Below is the simplest possible example of a Medusa HTTP server. It will run an HTTP server at port 8080, which will respond only with 404 responses. 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? =========== 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() When I run this, I get output like this: 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:193 >>> poll_fun(timeout, map) thon23\lib\asyncore.py:94 >>> def poll(timeout=0.0, map=None): thon23\lib\asyncore.py:95 >>> if map is None: thon23\lib\asyncore.py:97 >>> if map: thon23\lib\asyncore.py:98 >>> r = []; w = []; e = [] thon23\lib\asyncore.py:99 >>> for fd, obj in map.items(): hon23\lib\asyncore.py:100 >>> if obj.readable(): medusa\http_server.py:603 >>> def readable (self): medusa\http_server.py:604 >>> return self.accepting medusa\http_server.py:604 >>> return self.accepting hon23\lib\asyncore.py:101 >>> r.append(fd) hon23\lib\asyncore.py:102 >>> if obj.writable(): medusa\http_server.py:597 >>> def writable (self): medusa\http_server.py:598 >>> return 0 medusa\http_server.py:598 >>> return 0 thon23\lib\asyncore.py:99 >>> for fd, obj in map.items(): hon23\lib\asyncore.py:104 >>> if [] == r == w == e: hon23\lib\asyncore.py:107 >>> try: hon23\lib\asyncore.py:108 >>> r, w, e = select.select(r, w, e, timeout) 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? -- Graham