Skip to content

Refactoring create_db.py#153

Open
bralbral wants to merge 1 commit intofirefart:mainfrom
bralbral:master
Open

Refactoring create_db.py#153
bralbral wants to merge 1 commit intofirefart:mainfrom
bralbral:master

Conversation

@bralbral
Copy link
Contributor

@bralbral bralbral commented Mar 10, 2026

Hi!

The old version of the create_db.py code crashes with a divide-by-zero error.

Some logs:

/app/create_db.py:59: SyntaxWarning: "\s" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\\s"? A raw string is also an option.
  match = re.findall(b'^%s:\s?(.+)$' % (name), block, re.MULTILINE)
Process Process-6:
Traceback (most recent call last):
  File "/usr/local/lib/python3.14/multiprocessing/process.py", line 320, in _bootstrap
    self.run()
    ~~~~~~~~^^
  File "/usr/local/lib/python3.14/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/create_db.py", line 224, in parse_blocks
    percent = (BLOCKS_DONE * NUM_WORKERS * 100) / NUM_BLOCKS
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
ZeroDivisionError: division by zero
Process Process-2:
Traceback (most recent call last):
  File "/usr/local/lib/python3.14/multiprocessing/process.py", line 320, in _bootstrap
    self.run()
    ~~~~~~~~^^
  File "/usr/local/lib/python3.14/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/create_db.py", line 224, in parse_blocks
    percent = (BLOCKS_DONE * NUM_WORKERS * 100) / NUM_BLOCKS
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
ZeroDivisionError: division by zero


After refactoring the code, I fixed it and also eliminated the use of global variables.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant