From: Jeff A. <ja...@fa...> - 2017-03-29 20:05:17
|
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 |