Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Correct usage of python aerospike client in forked server
import random
import aerospike
import os, sys
cli = aerospike.client(
"hosts": [("aeros4", 3000), ("aeros1", 3000), ("aeros2", 3000), ("aeros3", 3000)],
"policies": {
"timeout": 10000,
"retry": aerospike.POLICY_RETRY_ONCE,
"shm": {}
if __name__ == '__main__':
a = cli.connect()
p = os.getpid()
for i in range(0,100):
child_pid = os.fork()
if child_pid == 0: break
# daemonize process
# if p == os.getpid(): sys.exit(0)
while True:
r = random.randint(1, 10000)
a.put(("test", "rand", r), {"val": r})
except Exception as e:
print("Error: {0}".format(e))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment