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 6131457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:58:39+00:00 2026-05-23T16:58:39+00:00

Here is a sample python script. How do I run this script multiple times

  • 0

Here is a sample python script. How do I run this script multiple times from command line so that the import line is not called every time? The import statement takes too long to load.

import arcpy
val = arcpy.GetCellValue_management("D:\dem-merged\lidar_wsg84", "-95.090174910630012 29.973962146120652", "")
print str(val)
  • 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-05-23T16:58:40+00:00Added an answer on May 23, 2026 at 4:58 pm

    This problem has no solution if you strictly want this script “to be called from another program. by issuing ‘python script.py’ on command line”.
    If you want to do the “heavy import” only once, you have to start python script only once.
    Think about starting a daemon, which will start once and then process calls from other program. This way all initialization has to be done only one time and next calls will be fast.
    And if you split your python code into two parts (first part for daemon, second for daemon client), you’ll be able to call ‘python client.py’ from another program, but actual computation will be performed by daemon, which is started just one time.

    As example:

    daemon.py

    import socket
    #import arcpy
    
    def actual_work():
        #val = arcpy.GetCellValue_management("D:\dem-merged\lidar_wsg84", "-95.090174910630012 29.973962146120652", "")
        #return str(val)
        return 'dummy_reply'
    
    
    def main():
        sock = socket.socket( socket.AF_INET, socket.SOCK_DGRAM )
        try:
            sock.bind( ('127.0.0.1', 6666) )
    
            while True:
                data, addr = sock.recvfrom( 4096 )
                reply = actual_work()
                sock.sendto(reply, addr)
        except KeyboardInterrupt:
            pass
        finally:
            sock.close()
    
    
    if __name__ == '__main__':
        main()
    

    client.py

    import socket
    import sys
    
    
    def main():
        sock = socket.socket( socket.AF_INET, socket.SOCK_DGRAM )
        sock.settimeout(1)
        try:
            sock.sendto('', ('127.0.0.1', 6666))
            reply, _ = sock.recvfrom(4096)
            print reply
        except socket.timeout:
            sys.exit(1)
        finally:
            sock.close()
    
    
    if __name__ == '__main__':
        main()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm running a script from crontab that will just ssh and run a command
I've set up this simple script on my local machine: #!/usr/bin/python import socket from
I'm trying to run Adobe's sample python policy server script, linked to here: http://www.adobe.com/devnet/flashplayer/articles/socket_policy_files.html
Here is my sample code: from xml.dom.minidom import * def make_xml(): doc = Document()
I am calling a python script with the following command line: myscript.py --myopt=[(5.,5.),(-5.,-5.)] The
So here's my problem. I have a python script that takes a zipfile and
I am new to Python and I have written this simple script: #!/usr/bin/python3 import
I'm trying to process a delicious rss feed via python. Here's a sample: ...
Here is a sample from Kernighan & Ritchie's The C Programming Language: int getline(char
Here is a sample code to retrieve data from a database using the yield

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.