'Registering a queue with an existing manager
Consider using SyncManager for server-client communication. The server may register a queue for communicating with the client like this:
from multiprocessing.managers import SyncManager
job_q = Queue()
class JobQueueManager(SyncManager):
pass
JobQueueManager.register('get_job_q', callable=lambda: job_q)
manager = JobQueueManager(address=('', port), authkey=authkey)
manager.start()
However, consider a situation whereby a new job queue needs to be created for each client connecting to the server (and a new client can connect at any time without a limit on the number of clients). In this case, we would need to call JobQueueManager.register after the construction of the manager object:
from multiprocessing.managers import SyncManager
class JobQueueManager(SyncManager):
pass
manager = JobQueueManager(address=('', port), authkey=authkey)
manager.start()
while True:
if new_client_connected: # handle connection of client named `client_name`:
job_q = Queue()
JobQueueManager.register(unique_queue_name(client_name), callable=lambda: job_q)
Unfortunately, for a reason I don't understand, register is a class method and so the newly registered method does not enter the dictionary of methods of manager. As a result, the client cannot obtain the queue by calling manager.queue_name_based_on_my_name(). Is there a way around this problem without changing the actual logic (such as pre-creating a pool of queues or making each client the server with respect to the queues for communicating with that client)?
Solution 1:[1]
From the documentation on the official MySQL Docker image (https://hub.docker.com/_/mysql):
If you start your mysql container instance with a data directory that already contains a database (specifically, a mysql subdirectory), the $MYSQL_ROOT_PASSWORD variable should be omitted from the run command line; it will in any case be ignored, and the pre-existing database will not be changed in any way.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Vlad |
