Directory Objects and altering them

Okay.....

 

Got a small plug-in, that scans the database and compares it towards the file-system.

 

Difference is shown in a DirectoryObject menu.

 

Now for my problem.....

 

If I scan a large section (In the filesystem) the API will time out on me...SNIFF....

 

So I was thinking about starting a separate thread for that, and then let that thread periodic issue a "still-alive" event/action/something.

 

Anybody got an idea as how to do that?

 

Code found here:

 

https://github.com/ukdtom/Plex-FindUnmatched

 

And would also welcome any devs to this plug-in as well

 

/Tommy

 

 

The dev docs regarding threading are available here. It takes a little to wrap one's head around it (at least that's what I found). There aren't many channels that use it. At one point the Trakt plugin was using it but I haven't followed that in quite a while so I'm not sure what it's doing now. The Unsupported Appstore uses threading when checking for updates to avoid similar time out issues. See the code here.

In regards to the way in which the results are presented the user, I recently stumbled across some code in the LetMeWatchThis plugin which is used to send an email notification to the user. You could probably implement it in your plugin to email the results. Check it here and here.

The dev docs regarding threading are available here. It takes a little to wrap one's head around it (at least that's what I found). There aren't many channels that use it. At one point the Trakt plugin was using it but I haven't followed that in quite a while so I'm not sure what it's doing now. The Unsupported Appstore uses threading when checking for updates to avoid similar time out issues. See the code here.

In regards to the way in which the results are presented the user, I recently stumbled across some code in the LetMeWatchThis plugin which is used to send an email notification to the user. You could probably implement it in your plugin to email the results. Check it here and here.

Hi Mike.

First of all....Huge thanx for responding here.

Already looked @ the API doc for threading, but sadly think it's above my league here....since this is my first attempt with Python and the API....(Tough learning curve, IMHO)

Did take a peek @ your code though, but, and sorry for my ignorance here, fail to see this as an API controlled threading?

I did notice the @parallelize statement, but fail to see how I can check for thread completeness?

Also FWIW, love your "thinking out of the box" attitude regarding SMTP, and I'll look into that as well, even though that could complicate matters, regarding firewall ports etc, so only as a last resort

Best Regards

Tommy

Hey Tommy,

the threading used in the UAS code is supported by the Plex Plugin Framework. TBH, I wouldn’t have the first clue about multi-threading otherwise :stuck_out_tongue_winking_eye:

I don’t recall whether there is any sort of report back from the thread regarding status beyond that it returns a result when the threaded task is complete. You could (spit-balling here) likely keep track of thread status yourself by managing a variable in the plugin Dict. Something like the following psuedo-code:

def ScanMenu():
  oc = ObjectContainer(no_cache=True)
  oc.add(DirectoryObject(key=Callback(StartScan), title="Scan Section"))
  if Dict['scan_status'] == "complete":
    oc.add(DirectoryObject(key=Callback(ShowResults), title="Results of Scan"))

return oc

def StartScan():
'''This needs to be threaded which I can't do from memory on my phone :P '''
#set the status variable while the scan runs
Dict['scan_status'] = "running"
#initiate the scan
... more code ...
# set the status variable complete when the scan finishes before exiting the thread
Dict['scan_status'] = "complete"
return

I totally get what you're saying about implementing email adding a whole nother layer of complexity. I can see why you wouldn't be keen on that. Another possibility would be allow the option for users to manually enter a directory path for the plugin to output the results. The file IO wouldn't be overly complex (I think). However, since none of the clients allow pasting into input boxes it pretty much limits the usefulness to the /Web client where users would be able to view the directory path on the computer and type it in using a keyboard. Again, just spitballing :)

There aren't many channels that use it.

Found this as well

https://github.com/plexinc-plugins/Vimeo.bundle

/Tommy

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.