Solved: Django Development Server Continues To Restart

Posted January 17th, 2012 in Django, General, Linux, Python by ryan

Hey ./manage.py runserver, Y U No Work?

Recently I was working on a Django-based project that integrates with Android and Embedded Linux devices. One day a coworker called me and asked about an error he had encountered. It seemed like he was not able to execute ./manage.py runserver to any port he had previously used. He was careful to use Control + C to stop the server, but for some reason the port was held onto by something. Looking at the output of “ps aux” was not showing any running processes using ./manage.py.

Who’s using that port?

Next instead of looking at processes, I wanted to see what was holding onto that port.  I ran the following command:

netstat -lpn | grep 8000

The output gave me the answer:

tcp    0    0 127.0.0.1:8000        0.0.0.0:*      LISTEN    15902/adb

So ADB was the culprit. A simple kill -9 to the process ID and the issue was fixed (temporarily). The issue keeps occuring, so maybe something in my code may be keeping ADB holding onto that port. I’m using the subprocess module to interact with ADB. I tried adding a call to terminate from the result of my subprocess.Popen call, but that ended very badly and had no effect on the hanging port. I’m sure when I have time to dig deeper (read “After My Looming Deadline”), I’ll try to write some tests to explore this issue more thoroughly.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Simple Fix: coercing to Unicode: need string or buffer, NoneType found

Posted April 17th, 2010 in Django, General, Python by ryan

Have you ever edited your models.py file and shortly after when trying to see the change list for a model in the admin site you received this error?

Caught an exception while rendering: coercing to Unicode: need string or buffer, NoneType found

I did today and it was one of those “bonehead” moments. You know, the one where you’ve been coding for a bit and for some reason make a simple error that leaves you thinking “I’ve done that exact same action a hundred times, why would I get an error this time?”, when you realize you made a really simple mistake. The answer was quick and easy. It was not occuring on the new model form, only on the change list so I opened my models file and looked over the model in question and then realized my typo. I had forgot to add “return” to the __unicode__ method on my model. So if you get this error, make sure that you’re returning something and that its really unicode.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Code Quality & Patch Quality

Posted September 9th, 2008 in Django, Open Source, Python by ryan

This was a great talk where Malcolm Tredinnick spelled out what he’s looking for in Django patches and what to avoid if you don’t want your patch tossed out.  Although his talk was targeting the Django project, he really dispensed good advice for anyone maintaining software regardless of project, language or platform.  The room was completely packed!  All of the chairs and couches we’re filled and people were sitting on the floor and standing at the sides of the room.

You’re doing it wrong if:

• the word “print” is in your patch
• you don’t have a test (fail before, pass afterwards)
• you think “PEP 8″ is an energy drink (PEP 8 is the style guide for python)
∘ make your patch look like django style code

Create patches by running diff from the top of the repository to get all changes.  The svn add command works locally even if you don’t have rights to commit to the repository so files you add will be added to the patch.

“Code style is opinionated and yours doesn’t matter!”

What he’s saying here makes sense in any open source project.  There’s a style defined and you should not deviate from it no matter how much you like your own special coding habits.  You might get away with minute changes, but don’t push it.

“Read the contributing document.”

This seems to be simple and common sense.  Skipping over information someone has left for you is a recipe for confusion.

Some tips given on comments:
• comments should last
• comments should be correct
• comments should explain they “why”, we can already read the how in the code.

Some general tips:
• Fix problems and not symptoms!
• Research is not a four letter word.
• The crowd is smarter than you

And what I believe was his last advice for the talk (at least I stopped taking notes after this) was to contribute and keep contributing.  Even when your patches don’t get in, don’t get discouraged.

It was a good talk and the first time I had heard Malcolm speak.  He was very informative and encouraging.  Overall I liked it and it was one of my favorite talks besides James Bennett and Cal Henderson.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

DjangoCon Update 1

Posted September 6th, 2008 in Uncategorized by ryan

I’m sitting next to the creator of python and listening to the History of Django talk.  It’s very interesting to see how the Django framework morphed into what we know it today.

Jacob Kaplan-Moss and Guido Van Rossum just had an interesting side discussion about how Django should do things, making it easier to run on Google App Engine.  After seeing Guido’s talk, the latest backend changes to allow a non rdbms database and the side conversation, I think there will be many exciting developments in Google App Engine in the next year.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Blogging From DjangoCon

Posted September 6th, 2008 in Django, General, Python by ryan

I’m here at the GooglePlex sitting a row away from the stage and enjoying the atmosphere.  It’s a great vibe here.  This does feel different than the Microsoft conferences I have been to.  Some observations so far is that the crowd seems a little younger for the most part and there is a comfortable atmosphere.  Of course there’s free food and drinks, free wifi, a great stage and screen for the presentations and the audio is flawless.  The only complaint I have thus far is the uncomfortable plastic daycare chairs.

Earlier I attended Guido’s App Engine keynote (blog post to follow later), and I’m now attending the High Performance Django talk.  I will try to make a post for each talk I attend.

Custom Ice Cream
Custom Ice Cream

Check back soon…

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]
FireStats icon Powered by FireStats