Skip to content

VarPyth fix for named parameters in multithreaded environment issue #125#126

Closed
mce2 wants to merge 1 commit intolmbelo:masterfrom
mce2:master
Closed

VarPyth fix for named parameters in multithreaded environment issue #125#126
mce2 wants to merge 1 commit intolmbelo:masterfrom
mce2:master

Conversation

@mce2
Copy link
Copy Markdown

@mce2 mce2 commented Apr 9, 2020

Supposed fix to Named parameters in VarPyth not cleared between function calls #125 issue. The patch is very inelegant, but I cannot see any side effects. As I understand, all data from named parameters is copied to a python object prior to do the actual function call, so truncation of fNamedParams should be OK at any moment.

…mbelo#125

Supposed fix to Named parameters in VarPyth not cleared between function calls lmbelo#125 issue. The patch is very inelegant, but I cannot see any side effects. As I understand, all data from named parameters is copied to a python object prior to do the actual function call, so truncation of fNamedParams should be OK at any moment.
@pyscripter
Copy link
Copy Markdown
Collaborator

pyscripter commented Apr 9, 2020

I don't see how this PR resolves the issue.

The problem is that fNamedParams is stored as a field of TPythonVariantType (singleton class). If multiple threads use Python Variants to make calls to Python you will still have problems,

Possible Solutions:

  • Make fNamedParams a Global threadvar
  • Store fNamedParams in a threadlist with the threadid and retrieve from there.
  • Store fNamedParams in TPythonData (one per variant) instead of TPythonVariantType (singleton class)
  • Store named arguments in the Arguments TVarDataArray, using some marker to separate standard from named arguments.

The first option is possibly the easiest to implement but threadvars come with their own performance penalty and limitations.

Why this flawed design

DispInvoke calls DoProcedure and DoFunction which then use EvalPython to do the work. The inherited DispInvoke does not make use of or deal with Named arguments and it needs to be overridden as well as DoProcedure and DoFunction. They all have a fixed signature, so you cannot for example pass another parameter from DispInvoke to DoFunction and you need to have some other means of passing fNamedParams from DispInvoke to DoFunction and then to EvalPython.

@pyscripter
Copy link
Copy Markdown
Collaborator

pyscripter commented Sep 23, 2020

I am closing this and I will try to implement a more solid solultion.

@pyscripter pyscripter closed this Sep 23, 2020
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