etwist/server.py
changeset 5655 ef903fff826d
parent 5654 8bb34548be86
parent 5652 904091dc4c7e
child 5679 0f2ded880d01
equal deleted inserted replaced
5654:8bb34548be86 5655:ef903fff826d
    23 import sys
    23 import sys
    24 import os
    24 import os
    25 import select
    25 import select
    26 import errno
    26 import errno
    27 import traceback
    27 import traceback
       
    28 import threading
    28 from os.path import join
    29 from os.path import join
    29 from time import mktime
    30 from time import mktime
    30 from datetime import date, timedelta
    31 from datetime import date, timedelta
    31 from urlparse import urlsplit, urlunsplit
    32 from urlparse import urlsplit, urlunsplit
    32 from cgi import FieldStorage, parse_header
    33 from cgi import FieldStorage, parse_header
   413             from pwd import getpwnam
   414             from pwd import getpwnam
   414             uid = getpwnam(config['uid']).pw_uid
   415             uid = getpwnam(config['uid']).pw_uid
   415         os.setuid(uid)
   416         os.setuid(uid)
   416     root_resource.start_service()
   417     root_resource.start_service()
   417     logger.info('instance started on %s', root_resource.base_url)
   418     logger.info('instance started on %s', root_resource.base_url)
       
   419     # avoid annoying warnign if not in Main Thread
       
   420     signals = threading.currentThread().getName() == 'MainThread'
   418     if config['profile']:
   421     if config['profile']:
   419         import cProfile
   422         import cProfile
   420         cProfile.runctx('reactor.run()', globals(), locals(), config['profile'])
   423         cProfile.runctx('reactor.run(installSignalHandlers=%s)' % signals,
       
   424                         globals(), locals(), config['profile'])
   421     else:
   425     else:
   422         reactor.run()
   426         reactor.run(installSignalHandlers=signals)