[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GEMPAK #MCL-633919]: gpend not clearing resources?
- Subject: [GEMPAK #MCL-633919]: gpend not clearing resources?
- Date: Thu, 06 May 2010 14:42:11 -0600
Hi Nancy,
Each instance of os.system in python will execute the given command in a
separate subshell, so while gdgrib is running in one, gpend will run in another
and will not be able to close the gplt process created by gdgrib (similar to
closing a terminal window before running gpend). My python isn't up to speed,
but it appears you should be able to execute multiple commands within the same
subshell to solve this problem.
This page seems to provide a thorough rundown of python system interfaces.
http://docs.python.org/library/os.html
Best,
Michael James
Unidata
> Full Name: Nancy Rehak
> Email Address: address@hidden
> Organization: NCAR/RAL
> Package Version: 5.11.4
> Operating System: Linux Debian 5.0.4
> Hardware:
> Description of problem: I'm using the GEMPAK gdgrib utility to convert GEMPAK
> files received from another organization into GRIB1 format. We are receiving
> the files in realtime so I'm using a Python script to call the gdgrib
> utility. I also call gpend after each gdgrib call to try to clear resources.
> However, after my Python script runs, I still see message queues and gplt
> processes. Here is what I'm doing in my Python script:
>
> #
> # Write the GEMPAK commands to a temporary file
> #
>
> pid = os.getpid()
> gfile_path = '/tmp/gempak_params.%d' % pid
> print "pid = ", pid
> print "gfile_path = ", gfile_path
> sys.stdout.flush()
>
> gfile = open(gfile_path, 'w')
>
> gfile.write("GDFILE=" + input_path + "\n")
> gfile.write("GFUNC=" + gfunc + "\n")
> gfile.write("GDATTIM=" + fcst + "\n")
> gfile.write("GLEVEL=0\n")
> gfile.write("GVCORD=NONE\n")
> gfile.write("GBTBLS=" + table + "\n")
> gfile.write("GBFILE=" + output_path + "\n")
> gfile.write("VERCEN=" + vercen + "\n")
> gfile.write("PDSVAL=" + pdsval + "\n")
> gfile.write("PRECSN=" + precsn + "\n")
> gfile.write("WMOHDR=\n")
> gfile.write("CPYFIL=\n")
> gfile.write("PROJ=\n")
> gfile.write("GRDAREA=\n")
> gfile.write("KXKY=\n")
> gfile.write("RUN\n")
>
> gfile.close()
>
> #
> # Run the GEMPAK command
> #
>
> print "About to run gdgrib"
> sys.stdout.flush()
>
> command = "gdgrib < " + gfile_path
> os.system(command)
>
> print "Ran gdgrib"
> sys.stdout.flush()
>
> # End the GEMPAK process
>
> print "About to run gpend"
> sys.stdout.flush()
>
> command = "gpend"
> os.system(command)
>
> print "Ran gpend"
> sys.stdout.flush()
>
> #
> # Delete the temporary file
> #
>
> os.remove(gfile_path)
>
> I believe I am successfully executing the gpend command because my log file
> contains the following:
>
> pid = 12459
> gfile_path = /tmp/gempak_params.12459
> About to run gdgrib
> GDFILE Grid file
> /d1/dtcrt/data/gempak/caps/ssef_s4c0_nmm/ssef_s4c0_nmm_2010050600f030
> GFUNC Scalar grid REFLCMP
> GDATTIM Grid date/time f030
> GLEVEL Grid level 0
> GVCORD Grid vertical coordinate NONE
> GBTBLS Input GRIB decoding tables
> /home/dtcrt/svn/projects/HWT/HWT2010/ingestHome/params/ncepgrib129.tbl
> GBFILE GRIB data file name
> /d1/dtcrt/data/grib/caps/ssef_s4c0_nmm/native/20100506/g_000000/20100507_060000.grb
> VERCEN PDS byte_4/byte_5/byte_6/byte_26 129/7/97/9
> PDSVAL GRIB PDS grid identifier overrid REFC%212
> PRECSN Packing precision b/-5
> WMOHDR WMO_ID/Origin_ID/DDHHMM
> CPYFIL Grid file whose navigation is to
> PROJ Map projection/angles/margins|dr
> GRDAREA Area covered by grid
> KXKY Number of grid points in x;y
> Parameters requested: GDFILE,GFUNC,GDATTIM,GLEVEL,GVCORD,GBTBLS,GBFILE,
> VERCEN,PDSVAL,PRECSN,WMOHDR,CPYFIL,PROJ,GRDAREA,KXKY.
> GEMPAK-GDGRIB> GEMPAK-GDGRIB> GEMPAK-GDGRIB> GEMPAK-GDGRIB> GEMPAK-GDGRIB>
> GEMPAK-GDGRIB> GEMPAK-GDGRIB> GEMPAK-GDGRIB> GEMPAK-GDGRIB> GEMPAK-GDGRIB>
> GEMPAK-GDGRIB> GEMPAK-GDGRIB> GEMPAK-GDGRIB> GEMPAK-GDGRIB> GEMPAK-GDGRIB>
> GEMPAK-GDGRIB> [GDGRIB 4] Warning: grid not found in
> grdnav.tbl...continuing.
> GRIB message written.
> Ran gdgrib
> About to run gpend
> Ran gpend
>
> However, after the Python script ends, I see the following:
>
> (taku) test 126 % ipcs
>
> ------ Shared Memory Segments --------
> key shmid owner perms bytes nattch status
>
> ------ Semaphore Arrays --------
> key semid owner perms nsems
>
> ------ Message Queues --------
> key msqid owner perms used-bytes messages
> 0x470a0004 0 rehak 666 0 0
> 0x440a0004 32769 rehak 666 0 0
> 0x00bc7bcf 83525634 dtcrt 666 0 0
> 0x02b90f66 83591171 dtcrt 666 0 0
> 0x00bc7c27 83656708 dtcrt 666 0 0
> 0x02b90f7c 83722245 dtcrt 666 0 0
>
> (taku) test 127 % ps auxww | grep gplt
> dtcrt 12534 0.0 0.0 21896 792 pts/2 S 11:24 0:00 gplt
> dtcrt 12556 0.0 0.0 21896 784 pts/2 S 11:24 0:00 gplt
> dtcrt 19599 0.0 0.0 3568 696 pts/10 S+ 11:35 0:00 grep gplt
>
> Any ideas of what I might be missing? This is the only GEMPAK processing I
> am doing on this machine at this time.
>
> Thanks!
>
>
>
Ticket Details
===================
Ticket ID: MCL-633919
Department: Support GEMPAK
Priority: Normal
Status: Open