From: Guy Gascoigne-P. <gg...@tr...> - 2003-01-09 00:11:55
|
I've got a very obscure problem that I've run out of ideas with and so I'm hoping that someone here might be able to shed some light upon it. We use jython in a multithreaded script execution engine. In simple terms we run many scripts concurrently using multiple PythonInterpreters, one per thread, managing thread and interpreter usage via thread pools etc. Here's a description of the test harness that I've got running that will eventually trigger the bug: We have a number of library scripts something like this: --- n_0.py class device: def name(self): return "0" --- n_1.py class device: def name(self): return "1" --- Then we have a number of main scripts: --- r_0.py dev = device.device() print dev.name() --- r_1.py dev = device.device() print dev.name() --- The intent here is that we have a system that applies rules to targets, but does so in such a way that the same rule can be applied to several targets types. To manage this, when we come to execute this we effectively do an import n_1 as device and then execute r_1 In an ideal world this should result in the number 1 being printed on standard out. I do this over about 100 scripts running with 20 threads in a pool and it works correctly, however every now and again (about 5% of the time) I start getting the wrong results. It appears that under some circumstances the import line doesn't work and the interpreter picks up a previous value for the import definition. Has anyone seen anything like this before or have any suggestions as to where to look to fix this? Guy -- "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." - Brian W. Kernighan |