Copy Protected PDFs and PIL

Alexander Gattin xrgtn at yandex.ru
Sun Nov 14 05:00:48 EST 2010


Hello,

On Fri, Nov 12, 2010 at 12:00:55PM -0800, Brett
Bowman wrote:
> MRAB -
> I've tried worker threads, and it kills the
> thread only and not the program as a whole.  I
> could use that as a work-around, but I would
> prefer something more direct, in case other
> problems arise.

Looks like the gfx module doesn't raise an
exception but terminates the thread instead
(strange that not the whole process -- I'd use
strace/truss/tusc to see what happens).

So running gfx's render() tasks in separate
threads or processes may be your only workaround.

BTW, when your child process dies it's good idea
to find out the cause of its death. So you can
check its:
* exitcode/WTERMSIG/WCOREDUMP
* stderr/stdout (if you run it through popen*())
* your own IPS, like e.g. child process sending
  some short message over the pipe/socket that
  describes what it's about to do (like in your
  example below): 
>         import gfx
>         print "1"
>         doc = gfx.open("pdf", MY_FILE)
>         print "2"
>         page1 = doc.getPage(1)
>         print "3"
>         g_img = gfx.ImageList()
>         print "4"
>         g_img.startpage(a_page.width,a_page.height)
>         print "5"
>         a_page.render(g_img)
>         print "6"
>         g_img.endpage()
>         print "7"
>         g_img.save(TEMP_PNG)
> 
> which prints the following:
> 
>         1
>         2
>         3
>         4
>         5
  This way a parent process can tell that its
  child most has died during
  a_page.render(g_img)... 

-- 
With best regards,
xrgtn



More information about the Python-list mailing list