Implementing the server

Our server will be implemented in the Python language. In this section, we will go through the script line by line, explaining each as we go along; you can type it in the file or download it from the repository.

So, let's open the MyToolboxServer.py file and go through its contents.

Imports

At the beginning, we need to import files that are necessary for the script to run:

import sys, glob
# path for file generated by Apache Thrift Compiler
sys.path.append('gen-py')
# add path where built Apache Thrift libraries are
sys.path.insert(0, glob.glob('thrift-0.9.2/lib/py/build/lib.*')[0])

These are the modules in the gen-py directory and the thrift-0.9.2 directory (the name depends on the exact Apache Thrift version you use).

Note ...

Get Learning Apache Thrift now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.