In __init__ or at the module level. Or simply use a global variable to check that the initialization has been performed.
And note that, for file type plugins, the plugin is run in a worker process, which means initialization including __init__ will happen once per worker process (and note that there can be multiple worker processes, and new worker processes can be created at any time). So if you are doing some initialization that needs to occur only once, not once per processes, you will need to use some kind of IPC locking mechanism, like a sentinel directory or a lock file or a global mutex.
Last edited by kovidgoyal; 12-15-2014 at 09:40 PM.
|