Skip to content

Commit 5226cd2

Browse files
committed
Create launch_gym_server.py
1 parent ed23e44 commit 5226cd2

File tree

1 file changed

+41
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)