Re: [cherrypy-users] Bus error, possibly from recursive call

85 views
Skip to first unread message

Sylvain Hellegouarch

unread,
Oct 17, 2012, 8:26:45 AM10/17/12
to cherryp...@googlegroups.com
Hi Eddie,

On Wed, Oct 17, 2012 at 2:19 PM, Eddie Sholl <eddie...@gmail.com> wrote:
Hi all,

I'm quite new to cherrypy, I've been playing around with it over the last few weeks and enjoying the simple and minimal approach taken with the framework. Ive been using it for a small project of mine, which is primarily for running a turn based strategy game engine, and an AI for playing that game.

I've run into a problem that Im having trouble investigating further. I'm basically just getting a 'Bus error' message in my console output, and everything dies at that point. The code that runs to produce the failure is a recursive method, and obviously thats not ideal to be running during a request. But my profiling and tracing suggests its only being called ~100 times before cherrypy falls over, and its only to a max depth of 2.


I've never come across a "Bus error" issue like you've had. Could you provide more context? What is your app, hence the bus, doing at the point where it dies?

 

So ive got a couple of questions that can help me deal with the issue. First of all, I was looking for a nice example of async request handling. The best hints so far are either the BackgroundTask or Monitor documented at http://docs.cherrypy.org/stable/refman/process/plugins/index.html#monitors (i'd really like to see an example to get my head around how to use these), or the wiki article http://tools.cherrypy.org/wiki/BackgroundTaskQueue. Is this how I should proceed to shift the load of my game AI out of a straight synchronous request handler?


If you don't mind threads and having everything within your main Python process, those are great. If you want something more distributed you could look at writing a plugin interfacing celery [1] or something similar.

You could get some inspiration from some recipes I wrote [2].


--
- Sylvain
http://www.defuze.org
http://twitter.com/lawouach

Walter Woods

unread,
Oct 17, 2012, 11:57:38 AM10/17/12
to cherryp...@googlegroups.com

Hey Eddie, just as an alternative to celery I thought I'd offer up lamegame_tasking (on github.com/wwoods).

Benefits over celery (up to you if you need them):

1.  It was designed for complicated architectures like games -
  A. support for task priorities
  B. scheduling events in the future
  C.  keeping a type of task running constantly while a user is logged in but letting it die off (saving you resources) when they're not
  D. Tasks with the ability to talk to each other without going through a database (again saves resources)
  E. Scheduled tasks
2. Has a status monitor that uses cherrypy

Downsides:

1. Less mature
2. Forced to use mongodb (I've been doing some speed tests recently, and this may be an upside ...)

Anyway, if you're interested let me know.  The docs are a tiny bit out of date sadly, but I'm still working on it and it has worked phenomenally forsho me so far.

-Walt

--
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to cherryp...@googlegroups.com.
To unsubscribe from this group, send email to cherrypy-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cherrypy-users?hl=en.

Eddie Sholl

unread,
Oct 19, 2012, 7:56:42 AM10/19/12
to cherryp...@googlegroups.com
HI all,

Thanks for your feedback. Initially I saw the 'Bus error' and assumed this was coming out of the cherrypy 'bus' feature, but its totally unrelated to that. The 'Bus error' I mentioned is just a plain old hard crash of python itself.

My recursion was blowing past the default stack size settings of python. Using threading.stack_size and sys.setrecursionlimit, I can get my app to run for longer, but its all just pointing to the fact that I need to rethink my basic use of recursion here. I'm going to have a play with stackless python, it seems to offer a bunch of advantages for what Im trying to do, including more efficient use of the stack (from what I've read so far).

Ideally I'd get to a solution where my cherrypy server and python runtime are totally isolated from terminal errors in my app logic, but thats probably some way down the track.

Cheers,
Eddie

Sylvain Hellegouarch

unread,
Oct 19, 2012, 8:31:19 AM10/19/12
to cherryp...@googlegroups.com
My recursion was blowing past the default stack size settings of python. Using threading.stack_size and sys.setrecursionlimit, I can get my app to run for longer, but its all just pointing to the fact that I need to rethink my basic use of recursion here. I'm going to have a play with stackless python, it seems to offer a bunch of advantages for what Im trying to do, including more efficient use of the stack (from what I've read so far).



If you go the stackless route, you may be interested in Nagare, a web framework built on top of it. 

Reply all
Reply to author
Forward
0 new messages