forked from Omegastick/pytorch-cpp-rl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlaunch_gym_server.py
executable file
·41 lines (34 loc) · 1.08 KB
/
launch_gym_server.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python
"""
Pytorch-cpp-rl OpenAI gym server main script.
"""
import logging
from gym_server.server import Server
from gym_server.zmq_client import ZmqClient
def main():
"""
Host the server.
"""
# If anything is logged during imports, it messes up our logging so we
# reset the logging module here
root_logger = logging.getLogger()
if root_logger.handlers:
for handler in root_logger.handlers:
root_logger.removeHandler(handler)
logging.basicConfig(level=logging.DEBUG,
format=('%(asctime)s %(funcName)s '
'[%(levelname)s]: %(message)s'),
datefmt='%Y%m%d %H:%M:%S')
logging.info("Initializing gym server")
zmq_client = ZmqClient(10201)
logging.info("Connecting to client")
zmq_client.send("Connection established")
logging.info("Connected")
server = Server(zmq_client)
try:
server.serve()
except: # pylint: disable=bare-except
import pdb
pdb.post_mortem()
if __name__ == '__main__':
main()