pyblish / pyblish-base

Pyblish base library - see https://github.com/pyblish/pyblish for details.
Other
123 stars 60 forks source link

Explicitly use targets without global registration #363

Closed buddly27 closed 4 years ago

buddly27 commented 4 years ago

The pyblish.util.publish() function (and all helpers for specific CVEI stage) can take a list of targets but pyblish.util._convenience_iter() uses the global registration in the backend, which causes a bunch of issues:

>>> pyblish.plugin.register_target("foo")
>>> print(pyblish.api.registered_targets())
["foo"]
>>> pyblish.util.publish(targets=["foo", "bar"])
>>> print(pyblish.api.registered_targets())
[]
>>> t1 = threading.Thread(target=pyblish.util.publish, kwargs={"targets": ["foo"]})
>>> t2 = threading.Thread(target=pyblish.util.publish, kwargs={"targets": ["bar"]})
>>> t1.start() # Register "foo"
>>> t2.start() # Register "bar" while t1 is still running...

It would be nice to modify the logic so that targets explicitly passed to these functions don't get registered globally. What do you think?