Wox-launcher / Wox

A cross-platform launcher that simply works
http://wox-launcher.github.io/Wox/
GNU General Public License v3.0
24.62k stars 2.37k forks source link

question about python plugin. Is main class object created everytime when user does a query? #3635

Closed xiezibuyongbi closed 1 year ago

xiezibuyongbi commented 2 years ago

I'm developing a wox plugin using python.
I found the attribute of object of Main class will be initialized everytime when method query is invoked.
Take an example:

class Main(Wox):
      attr = 1
      def query(self):
             with open('log.txt', 'a+') as logFile:
                   logFile.write(str(self.attr))
                   logFile.flush()
             self.attr = 2

And you will get only '1' everytime you do a query using wox. I guess wox create Main object everytime user does a query. Is that right?
If so, could any one tell me how to remain cache-like, stateful variable?
Thanks a lot!

qianlifeng commented 1 year ago

yes it is in v1, we have improve this in v2