Skip to content

Refactoring create_db.py#153

Closed
bralbral wants to merge 8 commits intofirefart:mainfrom
bralbral:master
Closed

Refactoring create_db.py#153
bralbral wants to merge 8 commits intofirefart:mainfrom
bralbral:master

Conversation

@bralbral
Copy link
Copy Markdown
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.

@firefart
Copy link
Copy Markdown
Owner

Why did you remove all comments and the whole last_modified fallback?

@bralbral
Copy link
Copy Markdown
Contributor Author

bralbral commented Apr 29, 2026

Why did you remove all comments and the whole last_modified fallback?

Sorry about that, my bad. I have re-added them.

Also, I have added an environment variable to connect to the database.

Additionally, export in mmdb format (MaxMind) has been added.

@firefart
Copy link
Copy Markdown
Owner

firefart commented May 7, 2026

please make single pull requests with small changes instead of those big ones. This is too much to review and test at once

@firefart firefart closed this May 7, 2026
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.

2 participants