Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7877523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:23:47+00:00 2026-06-03T03:23:47+00:00

I’m writing a web based code editor for Django projects. From within the editor

  • 0

I’m writing a web based code editor for Django projects. From within the editor I want to start the Django runserver command without it interfering with the server for the editor itself. Below is the code I use. The server (port 9999) is started but when I make a change to the code for the project whose server I just started both servers stop. The error is “That port is already in use”

def runserver(request, project_slug):
    project = Project.objects.get(slug=project_slug)
    import os
    os.system('cd %s; pwd; env; DJANGO_SETTINGS_MODULE=%s.settings; rm nohup.out; nohup python manage.py runserver 0.0.0.0:9999 &' % (project.get_current_directory(), project.slug))
    return HttpResponseRedirect(request.META['HTTP_REFERER'])   
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T03:23:48+00:00Added an answer on June 3, 2026 at 3:23 am

    You’ll need to invest some more work into managing the server you start. If you call runserver(request, project_slug) more than once, that resource is going to be already taken up by another background process that is bound to that port and right now you don’t even have a PID file to reference the process.

    You’ll need to add some gymnastics for starting/killing a WSGIServer and you’ll definitely need to use the socket low-level networking library to have it select a free port for you–defer from selecting a port manually because you cannot guarantee that another processes on your system won’t occupy the port and cause your application to get into an unrecoverable erroneous state.

    Fortunately, though, you have the open source Lettuce project that properly manages a Django server instance in the background on a separate thread. Here’s the actual code for the server, which I encourage you to see and adopt for your own purposes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
Specifically, suppose I start with the string string =hello \'i am \' me And
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.