Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue #98 - Crash when using the mongod_port parameter #105

Merged
merged 1 commit into from
Mar 17, 2024
Merged

Fix issue #98 - Crash when using the mongod_port parameter #105

merged 1 commit into from
Mar 17, 2024

Conversation

ercaronte
Copy link
Contributor

@ercaronte ercaronte commented Mar 11, 2024

This PR fixes issue #98
When when using the mongod_port parameter the library code crashes with the following exception:

  File "/.../lib/python3.12/site-packages/pymongo_inmemory/mongod.py", line 143, in start
    self._proc = subprocess.Popen(boot_command)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../lib/python3.12/subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/.../lib/python3.12/subprocess.py", line 1883, in _execute_child
    self.pid = _fork_exec(
               ^^^^^^^^^^^
TypeError: expected str, bytes or os.PathLike object, not int

The cause of the error is that the subprocess.Popen method does not accept int arguments, while the mongod_port parameter is forced as integer.

The mongod port value is set as str in all cases, except when passed as a customer parameter.
The proposed code change fixes this case.

the parameter mondod_port can not be an integer when passed to the subprocess.Popen command
@ercaronte ercaronte changed the title Crash when using the mondod_port parameter Crash when using the mongod_port parameter Mar 11, 2024
@ercaronte ercaronte changed the title Crash when using the mongod_port parameter Fix issue #98 - Crash when using the mongod_port parameter Mar 11, 2024
@ercaronte
Copy link
Contributor Author

@ekarademir or @david-molnar-oculai can you please have a look at this PR?

@david-molnar-oculai
Copy link
Contributor

Nice, I think I also run into this problem before. It's just annoying. Thanks for the fix.

@dgk675
Copy link

dgk675 commented Mar 15, 2024

Thanks, this solved my issue! A temporary workaround is to configure the Port as a str in setup.cfg

@ekarademir ekarademir merged commit 948a629 into kaizendorks:master Mar 17, 2024
@ekarademir
Copy link
Collaborator

This is now published. Thank you for the contribution @SparksFlyx3

jannesarja-processmaker pushed a commit to Workfellow-Open-Source/pymongo_inmemory that referenced this pull request Aug 20, 2024
the parameter mondod_port can not be an integer when passed to the subprocess.Popen command
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.

5 participants