Opened 8 years ago

Closed 6 years ago

Last modified 3 years ago

#364 closed defect (fixed)

Use the "full" Python thread API

Reported by: olly Owned by: olly
Priority: normal Milestone: 1.3.0
Component: Xapian-bindings (Python) Version: SVN trunk
Severity: normal Keywords:
Cc: dnsauve@…, alex@… Blocked By:
Blocking: Operating System: All

Description

This bug is essentially "son of #185".

Most of the issues in that ticket are fixed, but the requirement to run Xapian-using code in the main interpreter when using mod_python or mod_wsgi remains.

Mark Hammond gives a good summary of what needs doing for this in comment:ticket:185:3 - essentially we would need to use the full Python thread API and keep a reference to "our" Python interpreter in thread local storage.

I think doing this won't require modifications to SWIG (though perhaps we should ultimately offer a patch to SWIG to provide this as an option) - you can override what SWIG uses in the blocking/allowing thread begin/end boilerplate, so I think someone "just" needs to write suitable replacements which store the interpreter in thread local storage which we can plug in to our interface files.

Attachments (2)

python-multiinterpreter-locking.patch (3.2 KB) - added by olly 6 years ago.
Patch to implement locking using the "full" thread API
python.i-diff-against-reformatted-original.patch (1.6 KB) - added by olly 6 years ago.
patch against reformatted original to show actual changes better

Download all attachments as: .zip

Change History (11)

comment:1 Changed 8 years ago by notanumber

  • Cc dnsauve@… added

comment:2 Changed 7 years ago by olly

  • Resolution fixed deleted
  • Status changed from closed to reopened

Fixing status - was closed by spammer.

comment:3 Changed 7 years ago by sk1p

  • Cc alex@… added

comment:4 Changed 7 years ago by olly

  • Component changed from Xapian-bindings to Xapian-bindings (Python)

comment:5 Changed 7 years ago by olly

  • Milestone set to 1.2.x
  • Version changed from 1.1.0 to SVN trunk

This should cause any incompatibilities for existing code using the Python bindings, so marking as suitable for 1.2.x.

Changed 6 years ago by olly

Patch to implement locking using the "full" thread API

comment:6 Changed 6 years ago by olly

  • Milestone changed from 1.2.x to 1.3.0

This patch against current trunk works for the single interpreter case - I've not tested it in the multiple interpreter case yet, but I think it's at least along the right lines.

The patch also tweaks pythontest2.py to use threads so that the thread locking actually does something.

Marking for 1.3.0 - assuming this patch (or something like it) works, fixing this in 1.3.0 should give us plenty of time to shake out any problems.

Changed 6 years ago by olly

patch against reformatted original to show actual changes better

comment:7 Changed 6 years ago by olly

  • Resolution set to fixed
  • Status changed from reopened to closed

Applied to trunk with some additional changes in r16201.

comment:8 Changed 5 years ago by julefrokost

I have tested this and it works ok for multiple interpreter case also.

Kind regards.

julefrokost.


milestone changed from 1.2.x to 1.3.0 This patch against current trunk works for the single interpreter case - I've not tested it in the multiple interpreter case yet, but I think it's at least along the right lines.


This patch against current trunk works for the single interpreter case - I've not tested it in the multiple interpreter case yet, but I think it's at least along the right lines. julefrokost

The patch also tweaks pythontest2.py to use threads so that the thread locking actually does something.

comment:9 Changed 5 years ago by olly

julefrokost: This patch has already been included on trunk and in the 1.3.0 development release - are you just providing additional testing info, or are you suggesting these changes should get backported to 1.2.x? If so, which Xapian version did you test with and what tests did you do?

Note: See TracTickets for help on using tickets.