[Twisted-Python] adding endpoint plugins

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Wed Apr 30 08:14:16 MDT 2014


On 01:42 pm, dstainton415 at gmail.com wrote:
>Greetings,
>
>
>http://twistedsphinx.funsize.net/projects/core/howto/plugin.html

Note that's a random version of the documentation from who knows how 
long ago.  If you want a random version of the documentation then I 
suggest using http://twisted.readthedocs.org/en/latest/ instead.
>
>suggests that I can also set the PYTHONPATH to a directory:

Sure.  As a development environment trick.  Putting the module defining 
your plugin into *the* twisted/plugins/ directory will reduce your 
runtime cost.  This is purely a deployment decision, though, so if you'd 
rather expand PYTHONPATH then you can.
>
>"""if a directory which has been added to sys.path (typically by
>adding it to the PYTHONPATH environment variable) contains a directory
>named twisted/plugins/ , each .py file in that directory will be
>loaded as a source of plugins."""
>
>I'm using twisted 13.2.0 in a virtualenv... and I've tried setting
>PYTHONPATH to a "twisted/plugins" directory no avail. I must be doing
>something wrong here but after scouring the docs and twisted source
>code... I'm just not sure.

I don't think there's enough information here to debug your problem. 
Try coming up with an http://sscce.org/ or at least providing all of the 
details about your setup - the exact value of PYTHONPATH, the command 
you use to launch the program, the working directory you use, the 
complete, exact filesystem hierarchy starting at the top-most directory 
containing any code you wrote or expect to be in use, etc.

Some random suggestions that have helped other people and might help you 
but who knows:

  * delete all the dropin.cache files you can find and try again
  * delete all the .pyc files you can find and try again
  * put absolute paths into PYTHONPATH, not relative paths
  * don't put "/foo/bar/twisted/plugins" into PYTHONPATH, put "/foo/bar"
  * Make sure your plugin *provides* the plugin interface and IPlugin. 
This is not the same *implementing* those interfaces.

Good luck,
Jean-Paul




More information about the Twisted-Python mailing list