Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #674 (closed defect: worksforme)

Opened 13 years ago

Last modified 12 years ago

opening urls to self with urllib

Reported by: eleddy@… Owned by: anonymous
Priority: normal Milestone: 0.9a5
Component: CherryPy Version: 0.9a3
Severity: normal Keywords:
Cc:

Description

I am trying to use urllib to open a page in controllers.py to perform xsl translation on it. ie...

urllib.urlopen('http://localhost:8080')

Calling this code outside of turbogears (in the shell) procedes with no issues. Putting this in controllers.py causes 2 additional python processes to spawn(4 total, there are normally 2) and they all freeze. No exceptions are thrown.

The same happens if my IP os replaced for localhost.

External URL's work fine in all places.

I am working on Windows XP. Please let me know if you need more information/help/whatever - I don't know the code well enough to submit a patch :|

Change History

comment:1 Changed 13 years ago by kevin

Where in controllers.py is this code? In a method, or just out in the module itself? I'd suggest bringing this up on the mailing list, as this is more of a question than an identified bug at this point.

comment:2 Changed 13 years ago by kevin

  • Status changed from new to closed
  • Resolution set to invalid

comment:3 Changed 13 years ago by simon

  • Status changed from closed to reopened
  • Version set to 0.9a3
  • Resolution invalid deleted
  • Milestone set to 0.9a4

This seems to be a genuine bug (at least on winXP). To add to the confusion, running the same (controller) code via nosetests works fine.

comment:4 Changed 13 years ago by eleddy@…

In controllers.py, I was using this code to prepare data to be sent as a dictionary to the template engine. I don't know if this helps, but here is a stripped down version of the code I was trying to use:

  # controllers.py

  @turbogears.expose(format="xml")
  def rdf(self, portId=1857):
      xhtmlUri = 'http://localhost:8080/XXX A TG HOSTED URL XXX'
       # ... Doing Stuff Here .... #
 
      # this is where things get stuck
      xhtml = urllib.urlopen(xhtmlUri)

      #..... do more stuff .....#
      return something

comment:5 Changed 13 years ago by kevin

  • Milestone changed from 0.9a4 to 0.9a5

comment:6 Changed 13 years ago by alberto

Looks like a witty winXP thread/IPC deadlock... I'm not sure there's anything that can be done at the TG level to fix this (maybe at CP?)...

    @expose()
    def rdf(self, portId=1857):
        import urllib
        xhtmlUri = 'http://localhost:8080/'

        xhtml = urllib.urlopen(xhtmlUri)
        return "yeah!"

works like a charm in my shinny PB.

I think it's normal that nosetests run fine as I *believe* create_request doesn't really spawn a real server as init_only is passed to cp.server.start

Alberto .

comment:7 Changed 13 years ago by Joost

  • Status changed from reopened to closed
  • Resolution set to worksforme

I have no problem running this code on windows. Be sure to set server.tread_pool > 1 though ;)...

Note: See TracTickets for help on using tickets.