You are here: Home / Documentation / How To's / Checking which ZEO client is in use

Checking which ZEO client is in use

by nguyen — published Apr 03, 2014 12:04 PM, last modified Aug 16, 2016 10:49 AM
code to determine which ZEO client is serving the current request

Sometimes you want to ensure that a Script (Python) runs only on a specific ZEO client.  

Here is some code that checks if the script is being executed on one of our non-public admin ZEO clients (which always use a *082 port, e.g. 8082, 9082) as opposed to our publicly accessible load-balanced ZEO clients (8080, 8081, 8083, etc.):

request = container.REQUEST

port = request.SERVER_PORT
if int(port) % 1000 == 82:
   print "OK: using an admin ZEO client"
else:
   print "NOT using an admin ZEO client"

return printed
 

You could insert this at the top of any Script (Python) that should run only on a non-public admin ZEO client:

port = request.SERVER_PORT
if int(port) % 1000 != 82:
   return "NOT using an admin ZEO client"

 

Navigation