[spam] [archive] [hacking] Working on finalising a mobile python driver.
It's hard for me to do stuff, so when I really do something I hunker down and ignore everything else. Somewhat described elsewhere on-list. Right now I'm running into a frustrating issue. I've encountered similar issues before, in other languages, but this is the first one I've really butted heads with in Python. My python codebase currently crashes. One of parts may relate to object lifetime between android's java garbage collector and python's garbage collector. A strange behavior is that my python object is getting multiply constructed. I use the python object in a loop. It's constructed before the start of the loop, and then repeatedly called inside the loop, inside a try handler inside which an exception is thrown. I've done a textual search on the code and believe prior to that loop to be the only place the constructor is called. However, when I put a debugging line inside the constructor, the line is output every iteration of the loop. This particular python object is not intertwined with java, but inside the loop it produces a python object that is linked to java via the jni and cpython, and adds it as a member. I have output the traceback inside the constructor, and the traceback is empty. The only line is the constructor itself, as if a thread was started with the constructor as the thread functions. [*relief] It looks like even on the first call, the traceback has only one line. Maybe this is because it uses python's async feature. But constructers never use the async feature, so this must be a bug in the traceback.
I fixed the traceback output by manually calling python's traceback functions. The traceback gives a line for what caused the spurious constructor calls. It is the evaluation of a java constant. There is nothing else in the traceback between the java constant and the constructor. I move the java constant evaluation to static scope, instead of inside a method. The java-to-python library I am using is pyjnius. It is widely use in all kivy android applications. Last I checked, it was no longer maintained, but I talked about that in their community a little and some people who weren't familiar with it but had access merged some pull requests. I believe those merges haven't been released yet and aren't likely in the code I am using. It's 05:48 -0500 and 'here I go' trying the constructor logging with the java constants accessed at module scope!
The problem still occurs, with a different line in the same method listed in the traceback. It used to line 84. Now it is line 83. But because I added some module-scope definitions, the method body has shifted down and it's a different part of the logic.
The line is a call to python's asyncio functions, but none of the function content is in the traceback. I add output statements to determine when the the instruction pointer is jumping. On 1/14/21, Karl <gmkarl@gmail.com> wrote:
The problem still occurs, with a different line in the same method listed in the traceback.
It used to line 84. Now it is line 83. But because I added some module-scope definitions, the method body has shifted down and it's a different part of the logic.
None of my output statements, which I only added to that method, output anything, but one of them is listed in the traceback. I rebuild just to make sure. On 1/14/21, Karl <gmkarl@gmail.com> wrote:
The line is a call to python's asyncio functions, but none of the function content is in the traceback.
I add output statements to determine when the the instruction pointer is jumping.
On 1/14/21, Karl <gmkarl@gmail.com> wrote:
The problem still occurs, with a different line in the same method listed in the traceback.
It used to line 84. Now it is line 83. But because I added some module-scope definitions, the method body has shifted down and it's a different part of the logic.
(to clarify, a line number between two of them, not the output call, was in the traceback) adding output to the function that calls that one On 1/14/21, Karl <gmkarl@gmail.com> wrote:
None of my output statements, which I only added to that method, output anything, but one of them is listed in the traceback. I rebuild just to make sure.
On 1/14/21, Karl <gmkarl@gmail.com> wrote:
The line is a call to python's asyncio functions, but none of the function content is in the traceback.
I add output statements to determine when the the instruction pointer is jumping.
On 1/14/21, Karl <gmkarl@gmail.com> wrote:
The problem still occurs, with a different line in the same method listed in the traceback.
It used to line 84. Now it is line 83. But because I added some module-scope definitions, the method body has shifted down and it's a different part of the logic.
it was a mistake hidden by a traceback error. i was using a library class method as an object method, and the class method constructs an object in it. On 1/14/21, Karl <gmkarl@gmail.com> wrote:
(to clarify, a line number between two of them, not the output call, was in the traceback) adding output to the function that calls that one
On 1/14/21, Karl <gmkarl@gmail.com> wrote:
None of my output statements, which I only added to that method, output anything, but one of them is listed in the traceback. I rebuild just to make sure.
On 1/14/21, Karl <gmkarl@gmail.com> wrote:
The line is a call to python's asyncio functions, but none of the function content is in the traceback.
I add output statements to determine when the the instruction pointer is jumping.
On 1/14/21, Karl <gmkarl@gmail.com> wrote:
The problem still occurs, with a different line in the same method listed in the traceback.
It used to line 84. Now it is line 83. But because I added some module-scope definitions, the method body has shifted down and it's a different part of the logic.
participants (1)
-
Karl