From: Stefan R. <Ste...@gm...> - 2017-03-29 21:08:36
|
> Your elements array should be twice as long, I think? Obviously it should ;) Agreed on all points. I just tested the implementation and observed that an entry in globalThreadStates yields a null-PyFrame. How should we deal with that? a) Is it a bug and we should investigate how it can be null and solve it? b) set the frame to None in result of _current_frames c) skip such elements and let _current_frames only return a reduced dict? @Fabio regarding b), would PyDev be robust against None-values here? Despite this, the result looks rather much like in CPython. > Gesendet: Mittwoch, 29. März 2017 um 22:04 Uhr > Von: "Jeff Allen" <ja...@fa...> > An: jyt...@li... > Betreff: Re: [Jython-dev] Support for sys._current_frames > > This seems to be a faithful equivalent to the CPython implementation. > That is wrapped in a synchronisation construct, but globalThreadStates > is of a thread-safe class, I see. However, as the number of threads > might change between the call to size() and the call to toArray(), I > think it would be better to let toArray() always allocate the array > (i.e. give it a zero-length prototype). > > Your elements array should be twice as long, I think? > > The way we manage ThreadState and interpreters leaves me uneasy, but > that's not a criticism against this proposal, except for the risk of > change when the penny finally drops. > > Oh, and thanks to Fabio for continuing to support Jython in PyDev. > > Jeff Allen > > On 29/03/2017 17:30, Stefan Richthofer wrote: > > I suggest this could be implemented in ThreadStateMapping like this: > > (on top of that an implementation in PySystemState is straight forward) > > public static PyObject _current_frames() { > > @SuppressWarnings("unchecked") > > Map.Entry<Thread, ThreadState>[] entries = new > > Map.Entry[globalThreadStates.size()]; > > entries = globalThreadStates.entrySet().toArray(entries); > > PyObject elements[] = new PyObject[entries.length]; > > int pos = 0; > > for (Map.Entry<Thread, ThreadState> entry: entries) { > > elements[pos++] = Py.newInteger(entry.getKey().getId()); > > elements[pos++] = entry.getValue().frame; > > } > > return new PyDictionary(elements); > > } > > Opinions? > > -Stefan > > *Gesendet:* Mittwoch, 29. März 2017 um 17:30 Uhr > > *Von:* "Fabio Zadrozny" <fa...@gm...> > > *An:* "Jython Developers" <jyt...@li...> > > *Betreff:* [Jython-dev] Support for sys._current_frames > > Hi Jython devs, > > I've just updated the PyDev debugger to drop support for older Python > > versions and it seems I ended up breaking debugging in the current > > Jython version because of it... > > The issue is that PyDev now requires sys._current_frames to be > > implemented by the interpreter (available since Python 2.5), but it > > seems this is not available for Jython -- this is needed so that the > > debugger can be faster (i.e.: it runs with untraced frames until some > > breakpoint is actually added -- at that point it gets the current > > frames and sets the tracing in them). > > So, I'd like to check how feasible it'd be to have this support in Jython. > > Thanks, > > Fabio > > ------------------------------------------------------------------------------ > > Check out the vibrant tech community on one of the world's most > > engaging tech sites, Slashdot.org! > > http://sdm.link/slashdot_______________________________________________ > > Jython-dev mailing list Jyt...@li... > > https://lists.sourceforge.net/lists/listinfo/jython-dev > > > > > > ------------------------------------------------------------------------------ > > Check out the vibrant tech community on one of the world's most > > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > > > > > > _______________________________________________ > > Jython-dev mailing list > > Jyt...@li... > > https://lists.sourceforge.net/lists/listinfo/jython-dev > > > ------------------------------------------------------------------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > _______________________________________________ > Jython-dev mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-dev > |