Files
seweb/secop-webserver
zolliker 1201801170 break busy loop blocking the server
- Use gevent.sleep with a tiny value after a message has been
  received instead of no call to sleep at all. This was the
  reason for the webserver to block when used with prep8
  and the leiden dil with a lot of data
- move gevent.monkey.patch_all() to secop-webserver
- properly close clients
2026-05-04 13:19:33 +02:00

47 lines
1.7 KiB
Python
Executable File

#!/usr/bin/env python
from gevent import monkey
monkey.patch_all()
import sys
# look for sehistory and frappy
sys.path.extend(['/sq_sw/linse', '/sq_sw/linse/frappy'])
import argparse
from webserver import server
from base import Client
from influxgraph import InfluxGraph
from secop import SecopInteractor
from sehistory.seinflux import SEHistory
def parseArgv(argv):
parser = argparse.ArgumentParser(
description="start a webserver for history and interaction",
)
# loggroup = parser.add_mutually_exclusive_group()
# loggroup.add_argument("-v", "--verbose",
# help="Output lots of diagnostic information",
# action='store_true', default=False)
# loggroup.add_argument("-q", "--quiet", help="suppress non-error messages",
# action='store_true', default=False)
parser.add_argument("port",
type=str,
help="port number to serve\n")
# parser.add_argument('-d',
# '--daemonize',
# action='store_true',
# help='Run as daemon',
# default=False)
parser.add_argument('-i',
'--instrument',
action='store',
help="instrument, if running on an instrument computer\n"
"if the value is 'this', take the host name as instrument name",
default=None)
return parser.parse_args(argv)
args = parseArgv(sys.argv[1:])
instrument = None if args.instrument=='this' else args.instrument
server.run(int(args.port), SEHistory(), InfluxGraph, Client, single_instrument=instrument, secop=SecopInteractor)