![]() |
#1 |
Junior Member
![]() Posts: 6
Karma: 10
Join Date: Mar 2020
Device: nonde
|
IPC between plugin and interface
Hi!
I need to do a Google login for my plugin. Reading the documentation, I see that I need to launch that in a separate process. However I don't have a way to communicate back information to my plugin (mainly access and refresh tokens). I took a look at how other core plugins do it and it seems to use the IPC utils, but only some predefined messages are handled and it is currently not possible to register an handle for new message types. Is there any way I could make that work? Thanks! |
![]() |
![]() |
![]() |
#2 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 44,955
Karma: 26594922
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
A plugin can run arbitrary code (the only exception being it cant use Qt WebEngine), you can do IPC however you like. Use the python multiprocessing classes or a simple socket or stdin/stdout, or a file in the filesystem, whatever you are comfortable with.
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Junior Member
![]() Posts: 6
Karma: 10
Join Date: Mar 2020
Device: nonde
|
Ha yes that makes sense, thanks!
Other small question, is the networkauth module included in the main process? I would like to use QOAuth2AuthorizationCodeFlow if possible. |
![]() |
![]() |
![]() |
#4 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 44,955
Karma: 26594922
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
No, I dont think so. You can see th elist of Qt modules included by looking at sources.json in the calibre source tree.
|
![]() |
![]() |
![]() |
#5 |
Junior Member
![]() Posts: 6
Karma: 10
Join Date: Mar 2020
Device: nonde
|
I tried using the multiprocessing Queue class, but it doesn't seem possible to pass it through the IPC. From what I understand what the IPC module does:
Job -> Worker -> ConnectedWorker -> Sends the kwargs to the worker via pipe But the only way to send a Queue is when you spawn the child process, otherwise you get an error: Queue objects should only be shared between processes through inheritance. I will try to use a Dispatcher with a Job result to see if that works. |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 44,955
Karma: 26594922
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
I would strongly recommend against sending anything other than primitive data types such as strings/numbers and list/dicts of those between processes. If you want to do cross process synchronization use a lockfile or platform specific mutexes. Sending a queue requires shared memory which may or may not be available depending on platform.
|
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Device Plugin] Apple iDevice interface | GRiker | Plugins | 68 | 07-24-2013 12:06 PM |
Touch Kobo Touch Plugin Interface | ah- | Kobo Developer's Corner | 271 | 05-11-2013 04:53 AM |
Reset Sony Device Interface plugin? | NLight95 | Devices | 2 | 04-04-2011 06:40 PM |
Writing an interface action plugin | kiwidude | Plugins | 21 | 11-11-2010 04:11 PM |
Device interface plugin - nook | badmadbug | Plugins | 2 | 09-06-2010 11:03 AM |