Conversation
shaharyarn
left a comment
There was a problem hiding this comment.
Just adjust accordingly to the CR of marine-core and it's good.
marine/marine.py
Outdated
|
|
||
| from . import encap_consts | ||
|
|
||
| MARINE_ALREADY_INITIALIZED_ERROR_CODE = -2 |
There was a problem hiding this comment.
Remember to switch to the const from marine.h.
marine/marine.py
Outdated
| self._marine.marine_free.argtypes = [MARINE_RESULT_POINTER] | ||
| return_code = self._marine.init_marine() | ||
| if return_code < 0: | ||
| if return_code == c_int.in_dll(self._marine, 'MARINE_ALREADY_INITIALIZED_ERROR_CODE').value: |
There was a problem hiding this comment.
Run black on your code please :)
marine/marine.py
Outdated
| self._marine.marine_free.argtypes = [MARINE_RESULT_POINTER] | ||
| return_code = self._marine.init_marine() | ||
| if return_code < 0: | ||
| if return_code == c_int.in_dll(self._marine, 'MARINE_ALREADY_INITIALIZED_ERROR_CODE').value: |
There was a problem hiding this comment.
I really don't like this magic string.. :(
There was a problem hiding this comment.
I like the const that was defined. I think it's better than a long magic string.
Another option might be to expose the error code as the return value of a function (get_marine_already_initialized_err_code()) and not a const but that's weird
There was a problem hiding this comment.
Yeah that a bit weird, @yehonatanz @shaharyarn what do you guys think?
There was a problem hiding this comment.
@tomlegkov name of a function is no less magic than name of a const, it bothers you just because the latter is in quotes.
An AttributeError will be raised if this const symbol won't exist anyway and neither way is detected by static analysis.
There is a flag in marine-core that's preventing Marine from initializing twice.
In case Marine was already started, init_marine() returns
-2.