Re: [google-appengine] Background work with the deferred library

2011-06-04 Thread Robert Kluin
Hi Doug,
  This is probably happening because the function you're trying to
defer is defined in the request handler.  Move the function you want
to defer to another module (a different python file) and import it
from there.

  This limitation is mentioned in the deferred article (see the
limitations section).
http://code.google.com/appengine/articles/deferred.html


Robert







On Fri, Jun 3, 2011 at 20:54, Doug douglas.alex.w...@gmail.com wrote:
 I am having some problems with the deferred.py. When I try to run a
 stand-alone function (i.e. not a class method) such as:

 from google.appengine.ext import deferred

 def easything(n):
    print easy %s % n

 for thing in longlist:
    deferred.defer(easything, thing)

 I get this in the log:
 File C:\Program Files\Google\google_appengine\google\appengine\ext
 \deferred\deferred.py, line 129, in run
    raise PermanentTaskFailure(e)
 PermanentTaskFailure: 'module' object has no attribute 'easything'


 After reading through the documentation again and again I noticed this
 in the documentation
 http://code.google.com/appengine/articles/deferred.html

 from google.appengine.ext import deferred

  def do_something_expensive(a, b, c=None):
      logging.info(Doing something expensive!)
      # Do your work here

  # Somewhere else
  deferred.defer(do_something_expensive, Hello, world!, 42, c=True)


 Is the function do_something_expensive supposed to be indented? I
 guess what I am getting at is can I feed stand alone functions into
 deferred.defer or do you have to only use methods (which would explain
 the indentation - I guess). . To add more color to this question I
 posted this on stackoverflow last night:
 http://stackoverflow.com/questions/6225400/problem-posting-to-datastore-with-deferred-defer-tasks
 I have found the error in the log since then, and have noticed that no
 matter how simple I make the function I am getting this error. I am
 not importing anything fancy.

 Thanks for any help I am new to programming in general.

 --
 You received this message because you are subscribed to the Google Groups 
 Google App Engine group.
 To post to this group, send email to google-appengine@googlegroups.com.
 To unsubscribe from this group, send email to 
 google-appengine+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/google-appengine?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To post to this group, send email to google-appengine@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.



[google-appengine] Background work with the deferred library

2011-06-03 Thread Doug
I am having some problems with the deferred.py. When I try to run a
stand-alone function (i.e. not a class method) such as:

from google.appengine.ext import deferred

def easything(n):
print easy %s % n

for thing in longlist:
deferred.defer(easything, thing)

I get this in the log:
File C:\Program Files\Google\google_appengine\google\appengine\ext
\deferred\deferred.py, line 129, in run
raise PermanentTaskFailure(e)
PermanentTaskFailure: 'module' object has no attribute 'easything'


After reading through the documentation again and again I noticed this
in the documentation
http://code.google.com/appengine/articles/deferred.html

from google.appengine.ext import deferred

  def do_something_expensive(a, b, c=None):
  logging.info(Doing something expensive!)
  # Do your work here

  # Somewhere else
  deferred.defer(do_something_expensive, Hello, world!, 42, c=True)


Is the function do_something_expensive supposed to be indented? I
guess what I am getting at is can I feed stand alone functions into
deferred.defer or do you have to only use methods (which would explain
the indentation - I guess). . To add more color to this question I
posted this on stackoverflow last night:
http://stackoverflow.com/questions/6225400/problem-posting-to-datastore-with-deferred-defer-tasks
I have found the error in the log since then, and have noticed that no
matter how simple I make the function I am getting this error. I am
not importing anything fancy.

Thanks for any help I am new to programming in general.

-- 
You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To post to this group, send email to google-appengine@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.