Skip to content

Commit

Permalink
start workers with the same database path
Browse files Browse the repository at this point in the history
otherwise temp databases could not be reached by workers
²
  • Loading branch information
denisri committed Oct 3, 2023
1 parent 2c551ad commit e036b2b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion capsul/database/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ def __exit__(self, exception_type, exception_value, exception_traceback):
self._exit()

def workers_command(self, engine_id):
db_config = self.worker_database_config(self.engine_id)
db_config = dict(self.worker_database_config(self.engine_id))
# fix db path in case it is different from the initial config
# (happens if path == '')
db_config['path'] = self.path
db_config = json.dumps(db_config, separators=(',', ':'))
workers_command = []
config = self.engine_config(engine_id)
Expand Down
4 changes: 3 additions & 1 deletion capsul/database/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def _enter(self):
if self.path == '':
self._path = os.path.join(tmp, 'database.rdb')
self.redis_socket = f'{self.path}.socket'
print('start redis:', self._path, self.redis_socket)
dir, dbfilename = os.path.split(self.path)
pid_file = f'{tmp}/redis.pid'
log_file = f'{tmp}/redis.log'
Expand Down Expand Up @@ -94,7 +95,8 @@ def _enter(self):
f'Invalid Redis connection type: {self.config["type"]}')
if self.redis.get('capsul:shutting_down'):
raise RuntimeError(
'Cannot connect to database because it is shutting down')
'Cannot connect to database because it is shutting down: '
f'{self._path}: {self.redis_socket}')
self.redis.hset('capsul:connections', self.uuid,
datetime.now().isoformat())

Expand Down

0 comments on commit e036b2b

Please sign in to comment.