Skip to content

Commit

Permalink
Add identity to workers
Browse files Browse the repository at this point in the history
  • Loading branch information
munrojm committed Sep 26, 2022
1 parent ac1d70b commit d0c7c49
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/maggma/cli/distributed.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import numpy as np
from time import perf_counter
import asyncio
from random import randint

from monty.json import jsanitize
from monty.serialization import MontyDecoder
Expand Down Expand Up @@ -220,12 +221,14 @@ async def worker(url: str, port: int, num_processes: int, no_bars: bool):
Simple distributed worker that connects to a manager asks for work and deploys
using multiprocessing
"""
# Should this have some sort of unique ID?
logger = getLogger("Worker")
identity = "%04X-%04X" % (randint(0, 0x10000), randint(0, 0x10000))
logger = getLogger(f"Worker {identity}")

logger.info(f"Connnecting to Manager at {url}:{port}")
context = azmq.Context()
socket = context.socket(zmq.REQ)

socket.setsockopt_string(zmq.IDENTITY, identity)
socket.connect(f"{url}:{port}")

# Initial message package
Expand Down

0 comments on commit d0c7c49

Please sign in to comment.