Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #21606 > unrolled thread

Is it technically possible to give Python option of naming process of running script?

Started byxliiv <tymoteusz.jankowski@gmail.com>
First post2012-03-14 07:43 -0700
Last post2012-03-24 11:24 -0400
Articles 20 — 8 participants

Back to article view | Back to comp.lang.python


Contents

  Is it technically possible to give Python option of naming process of running script? xliiv <tymoteusz.jankowski@gmail.com> - 2012-03-14 07:43 -0700
    Re: Is it technically possible to give Python option of naming process of running script? Chris Angelico <rosuav@gmail.com> - 2012-03-15 02:13 +1100
      Re: Is it technically possible to give Python option of naming process of running script? Grant Edwards <invalid@invalid.invalid> - 2012-03-14 16:02 +0000
        Re: Is it technically possible to give Python option of naming process of running script? Terry Reedy <tjreedy@udel.edu> - 2012-03-14 13:13 -0400
          Re: Is it technically possible to give Python option of naming process of running script? Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2012-03-14 18:34 +0100
        RE: Is it technically possible to give Python option of naming process of running script? "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-03-14 17:20 +0000
        RE: Is it technically possible to give Python option of naming process of running script? "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-03-14 17:27 +0000
        Re: Is it technically possible to give Python option of naming process of running script? Dave Angel <d@davea.name> - 2012-03-14 22:15 -0400
        Re: Is it technically possible to give Python option of naming process of running script? xliiv <tymoteusz.jankowski@gmail.com> - 2012-03-15 00:24 -0700
        Re: Is it technically possible to give Python option of naming process of running script? xliiv <tymoteusz.jankowski@gmail.com> - 2012-03-15 00:26 -0700
          Re: Is it technically possible to give Python option of naming process of running script? Dave Angel <d@davea.name> - 2012-03-15 12:04 -0400
            Re: Is it technically possible to give Python option of naming process of running script? Grant Edwards <invalid@invalid.invalid> - 2012-03-15 18:39 +0000
              Re: Is it technically possible to give Python option of naming process of running script? Dave Angel <d@davea.name> - 2012-03-15 22:00 -0400
              Re: Is it technically possible to give Python option of naming process of running script? Chris Angelico <rosuav@gmail.com> - 2012-03-16 14:14 +1100
                Re: Is it technically possible to give Python option of naming process of running script? xliiv <tymoteusz.jankowski@gmail.com> - 2012-03-16 01:19 -0700
                Re: Is it technically possible to give Python option of naming process of running script? xliiv <tymoteusz.jankowski@gmail.com> - 2012-03-16 01:19 -0700
                Re: Is it technically possible to give Python option of naming process of running script? Grant Edwards <invalid@invalid.invalid> - 2012-03-16 13:27 +0000
                  RE: Is it technically possible to give Python option of naming process of running script? "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-03-16 20:14 +0000
                    Re: Is it technically possible to give Python option of naming process of running script? Grant Edwards <invalid@invalid.invalid> - 2012-03-16 20:54 +0000
    Re: Is it technically possible to give Python option of naming process of running script? Adam  Tauno Williams <awilliam@whitemice.org> - 2012-03-24 11:24 -0400

#21606 — Is it technically possible to give Python option of naming process of running script?

Fromxliiv <tymoteusz.jankowski@gmail.com>
Date2012-03-14 07:43 -0700
SubjectIs it technically possible to give Python option of naming process of running script?
Message-ID<19118128.4791.1331736187952.JavaMail.geo-discussion-forums@vbai14>
Like the topic.. .
I use Python a lot, both Windows and Linux, and it's little weird to have many python process without fast distinction which is what.

[toc] | [next] | [standalone]


#21608

FromChris Angelico <rosuav@gmail.com>
Date2012-03-15 02:13 +1100
Message-ID<mailman.637.1331738031.3037.python-list@python.org>
In reply to#21606
On Thu, Mar 15, 2012 at 1:43 AM, xliiv <tymoteusz.jankowski@gmail.com> wrote:
> Like the topic.. .
> I use Python a lot, both Windows and Linux, and it's little weird to have many python process without fast distinction which is what.

I've no idea if it's even possible on Windows. On Linux, what you want
is the prctl function, which (AFAIK) isn't directly available.

Google is your friend, though. Question's already been asked on Stack
Overflow and such, and has a few answers. Nothing that looks
cut-and-dried ready, but several that might work. Look for 'prctl' and
'PR_SET_NAME', which are the C-level function and constant that do the
job; a cursory examination of PyPI shows a module with prctl in the
name, so that may be of value.

ChrisA

[toc] | [prev] | [next] | [standalone]


#21609

FromGrant Edwards <invalid@invalid.invalid>
Date2012-03-14 16:02 +0000
Message-ID<jjqfdp$9ud$1@reader1.panix.com>
In reply to#21608
On 2012-03-14, Chris Angelico <rosuav@gmail.com> wrote:
> On Thu, Mar 15, 2012 at 1:43 AM, xliiv <tymoteusz.jankowski@gmail.com> wrote:
>> Like the topic.. .
>> I use Python a lot, both Windows and Linux, and it's little weird to have many python process without fast distinction which is what.
>
> I've no idea if it's even possible on Windows. On Linux, what you want
> is the prctl function, which (AFAIK) isn't directly available.
>
> Google is your friend, though. Question's already been asked on Stack
> Overflow and such, and has a few answers. Nothing that looks
> cut-and-dried ready, but several that might work.

The question of how to set the application name comes up somewhat
regularly. It would be awfully nice if there was a way for python
applications to set their application name.  It's especially useful
for daemons, and makes it much easier when you can kill them by name
instead of having to look up the PID.

It seems like an excellent thing to add to the "os" module.

> Look for 'prctl' and 'PR_SET_NAME', which are the C-level function
> and constant that do the job; a cursory examination of PyPI shows a
> module with prctl in the name, so that may be of value.

-- 
Grant Edwards               grant.b.edwards        Yow! TONY RANDALL!  Is YOUR
                                  at               life a PATIO of FUN??
                              gmail.com            

[toc] | [prev] | [next] | [standalone]


#21611

FromTerry Reedy <tjreedy@udel.edu>
Date2012-03-14 13:13 -0400
Message-ID<mailman.639.1331745244.3037.python-list@python.org>
In reply to#21609
On 3/14/2012 12:02 PM, Grant Edwards wrote:

> It seems like an excellent thing to add to the "os" module.

If 'prctl' is a standard POSIX system call, then it should be a 
candidate for inclusion in the os module if someone opens a tracker 
enhancement issue and presents an argument in favor.

-- 
Terry Jan Reedy

[toc] | [prev] | [next] | [standalone]


#21615

FromAlain Ketterlin <alain@dpt-info.u-strasbg.fr>
Date2012-03-14 18:34 +0100
Message-ID<87zkbjgk7p.fsf@dpt-info.u-strasbg.fr>
In reply to#21611
Terry Reedy <tjreedy@udel.edu> writes:

> On 3/14/2012 12:02 PM, Grant Edwards wrote:
>
>> It seems like an excellent thing to add to the "os" module.
>
> If 'prctl' is a standard POSIX system call, then it should be a
> candidate for inclusion in the os module if someone opens a tracker
> enhancement issue and presents an argument in favor.

It's not. The man page says "This  call  is  Linux-specific."

-- Alain.

[toc] | [prev] | [next] | [standalone]


#21612

From"Prasad, Ramit" <ramit.prasad@jpmorgan.com>
Date2012-03-14 17:20 +0000
Message-ID<mailman.640.1331745665.3037.python-list@python.org>
In reply to#21609
> > It seems like an excellent thing to add to the "os" module.
> 
> If 'prctl' is a standard POSIX system call, then it should be a
> candidate for inclusion in the os module if someone opens a tracker
> enhancement issue and presents an argument in favor.


I think this request was already denied: http://bugs.python.org/issue5672 

Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423

--

This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  

[toc] | [prev] | [next] | [standalone]


#21614

From"Prasad, Ramit" <ramit.prasad@jpmorgan.com>
Date2012-03-14 17:27 +0000
Message-ID<mailman.642.1331746058.3037.python-list@python.org>
In reply to#21609
> > > It seems like an excellent thing to add to the "os" module.
> >
> > If 'prctl' is a standard POSIX system call, then it should be a
> > candidate for inclusion in the os module if someone opens a tracker
> > enhancement issue and presents an argument in favor.
> 
> 
> I think this request was already denied: http://bugs.python.org/issue5672

Also take a look at: https://github.com/dvarrazzo/py-setproctitle 
Though since they just create a Named Object in Windows, I am not sure
it would work for something like killall.


Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423

--

This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  

[toc] | [prev] | [next] | [standalone]


#21643

FromDave Angel <d@davea.name>
Date2012-03-14 22:15 -0400
Message-ID<mailman.662.1331777775.3037.python-list@python.org>
In reply to#21609
On 03/14/2012 01:27 PM, Prasad, Ramit wrote:
>>>> It seems like an excellent thing to add to the "os" module.
>>> If 'prctl' is a standard POSIX system call, then it should be a
>>> candidate for inclusion in the os module if someone opens a tracker
>>> enhancement issue and presents an argument in favor.
>>
>> I think this request was already denied: http://bugs.python.org/issue5672
> Also take a look at: https://github.com/dvarrazzo/py-setproctitle
> Though since they just create a Named Object in Windows, I am not sure
> it would work for something like killall.
>
>

There is/was a project called exemaker for Windows.  (see Pypi for 
link).  I don't use Windows any more, but it was a nice trick, when it 
worked.  Not all python scripts could be wrapped in it, but basically it 
let you wrap a python script in a tiny Windows program which launched 
the usual python dll's.  You could call it anything you liked, and 
that's what the task manager saw as the process name.




-- 

DaveA

[toc] | [prev] | [next] | [standalone]


#21647

Fromxliiv <tymoteusz.jankowski@gmail.com>
Date2012-03-15 00:24 -0700
Message-ID<19923939.18.1331796298704.JavaMail.geo-discussion-forums@vbhz5>
In reply to#21609
> >> Like the topic.. .
> >> I use Python a lot, both Windows and Linux, and it's little weird to have many python process without fast distinction which is what.
> >
> > I've no idea if it's even possible on Windows. On Linux, what you want
> > is the prctl function, which (AFAIK) isn't directly available.
> >
> > Google is your friend, though. Question's already been asked on Stack
> > Overflow and such, and has a few answers. Nothing that looks
> > cut-and-dried ready, but several that might work.
> 
> The question of how to set the application name comes up somewhat
> regularly. It would be awfully nice if there was a way for python
> applications to set their application name.  It's especially useful
> for daemons, and makes it much easier when you can kill them by name
> instead of having to look up the PID.
> 
> It seems like an excellent thing to add to the "os" module.
> 
> > Look for 'prctl' and 'PR_SET_NAME', which are the C-level function
> > and constant that do the job; a cursory examination of PyPI shows a
> > module with prctl in the name, so that may be of value.


I did google, I've played with Exemaker (it works perfect, but not py3) and i've seen questions on Stackoverflow.
The thing I mean is a build feature of python to give such a name. Not 3rd part or etc. like Grant Edwards said. Is it possible?

[toc] | [prev] | [next] | [standalone]


#21648

Fromxliiv <tymoteusz.jankowski@gmail.com>
Date2012-03-15 00:26 -0700
Message-ID<22071354.8904.1331796412001.JavaMail.geo-discussion-forums@vbkc1>
In reply to#21609
> >> Like the topic.. .
> >> I use Python a lot, both Windows and Linux, and it's little weird to have many python process without fast distinction which is what.
> >
> > I've no idea if it's even possible on Windows. On Linux, what you want
> > is the prctl function, which (AFAIK) isn't directly available.
> >
> > Google is your friend, though. Question's already been asked on Stack
> > Overflow and such, and has a few answers. Nothing that looks
> > cut-and-dried ready, but several that might work.
> 
> The question of how to set the application name comes up somewhat
> regularly. It would be awfully nice if there was a way for python
> applications to set their application name.  It's especially useful
> for daemons, and makes it much easier when you can kill them by name
> instead of having to look up the PID.
> 
> It seems like an excellent thing to add to the "os" module.
> 
> > Look for 'prctl' and 'PR_SET_NAME', which are the C-level function
> > and constant that do the job; a cursory examination of PyPI shows a
> > module with prctl in the name, so that may be of value.


I did google, I've played with Exemaker (it works perfect, but not py3) and i've seen questions on Stackoverflow. 
The thing I mean is a build feature of python to give such a name. Not 3rd part or etc. like Grant Edwards said. Is it possible?

[toc] | [prev] | [next] | [standalone]


#21692

FromDave Angel <d@davea.name>
Date2012-03-15 12:04 -0400
Message-ID<mailman.687.1331827483.3037.python-list@python.org>
In reply to#21648
On 03/15/2012 03:26 AM, xliiv wrote:
>>>> Like the topic.. .
>>>> I use Python a lot, both Windows and Linux, and it's little weird to have many python process without fast distinction which is what.
>>
>
> I did google, I've played with Exemaker (it works perfect, but not py3) and i've seen questions on Stackoverflow.
> The thing I mean is a build feature of python to give such a name. Not 3rd part or etc. like Grant Edwards said. Is it possible?

How about simply using cp to copy the python executable, run chmod +x on 
it, and run that one?  Then ps would list it as the new name, not as python.

i tried it on /usr/bin/python2.7    but I see no reason the same 
approach won't work on 3.x  Note, I copied it to a new name in the same 
directory, which may be important.  or not.

-- 

DaveA

[toc] | [prev] | [next] | [standalone]


#21703

FromGrant Edwards <invalid@invalid.invalid>
Date2012-03-15 18:39 +0000
Message-ID<jjtd0f$t8t$1@reader1.panix.com>
In reply to#21692
On 2012-03-15, Dave Angel <d@davea.name> wrote:
> On 03/15/2012 03:26 AM, xliiv wrote:
>>>>> Like the topic.. .
>>>>> I use Python a lot, both Windows and Linux, and it's little weird to have many python process without fast distinction which is what.
>>>
>>
>> I did google, I've played with Exemaker (it works perfect, but not py3) and i've seen questions on Stackoverflow.
>> The thing I mean is a build feature of python to give such a name. Not 3rd part or etc. like Grant Edwards said. Is it possible?
>
> How about simply using cp to copy the python executable, run chmod +x on 
> it, and run that one?  Then ps would list it as the new name, not as python.

That's rather a waste of memory.  Better to use a link.  That way the
executable can still be shared by multiple programs and won't be
duplicated in memory.

> i tried it on /usr/bin/python2.7    but I see no reason the same 
> approach won't work on 3.x  Note, I copied it to a new name in the same 
> directory, which may be important.  or not.

Seems like an awfully obtuse way of doing things -- I don't really
want to have 15 different copies of Python (or even links), and it
requires root privleges every time you want to run a Python program
with the "correct" name.

-- 
Grant Edwards               grant.b.edwards        Yow! Can I have an IMPULSE
                                  at               ITEM instead?
                              gmail.com            

[toc] | [prev] | [next] | [standalone]


#21729

FromDave Angel <d@davea.name>
Date2012-03-15 22:00 -0400
Message-ID<mailman.712.1331863254.3037.python-list@python.org>
In reply to#21703
On 03/15/2012 02:39 PM, Grant Edwards wrote:
> On 2012-03-15, Dave Angel<d@davea.name>  wrote:
>> On 03/15/2012 03:26 AM, xliiv wrote:
>>>>>> Like the topic.. .
>>>>>> I use Python a lot, both Windows and Linux, and it's little weird to have many python process without fast distinction which is what.
>>> I did google, I've played with Exemaker (it works perfect, but not py3) and i've seen questions on Stackoverflow.
>>> The thing I mean is a build feature of python to give such a name. Not 3rd part or etc. like Grant Edwards said. Is it possible?
>> How about simply using cp to copy the python executable, run chmod +x on
>> it, and run that one?  Then ps would list it as the new name, not as python.
> That's rather a waste of memory.  Better to use a link.  That way the
> executable can still be shared by multiple programs and won't be
> duplicated in memory.
>
>> i tried it on /usr/bin/python2.7    but I see no reason the same
>> approach won't work on 3.x  Note, I copied it to a new name in the same
>> directory, which may be important.  or not.
> Seems like an awfully obtuse way of doing things -- I don't really
> want to have 15 different copies of Python (or even links), and it
> requires root privleges every time you want to run a Python program
> with the "correct" name.
>

Good point about using a link.  I was trying to make something that 
would probably also work in Windows. As for the needing of root 
privileges, that's only for those programs you need to be able to 
identify with ps, and only one time for each.

Anyway, it's a response to a specific need, which I don't share, and it 
was my second suggestion, not first.



-- 

DaveA

[toc] | [prev] | [next] | [standalone]


#21735

FromChris Angelico <rosuav@gmail.com>
Date2012-03-16 14:14 +1100
Message-ID<mailman.716.1331867645.3037.python-list@python.org>
In reply to#21703
On Fri, Mar 16, 2012 at 5:39 AM, Grant Edwards <invalid@invalid.invalid> wrote:
> Seems like an awfully obtuse way of doing things -- I don't really
> want to have 15 different copies of Python (or even links), and it
> requires root privleges every time you want to run a Python program
> with the "correct" name.

Why do you need root? Can't you copy / link into your own home directory?

I may have misunderstood something here.

ChrisA

[toc] | [prev] | [next] | [standalone]


#21739

Fromxliiv <tymoteusz.jankowski@gmail.com>
Date2012-03-16 01:19 -0700
Message-ID<mailman.719.1331885986.3037.python-list@python.org>
In reply to#21735
> > Seems like an awfully obtuse way of doing things -- I don't really
> > want to have 15 different copies of Python (or even links), and it
> > requires root privleges every time you want to run a Python program
> > with the "correct" name.
> 
> Why do you need root? Can't you copy / link into your own home directory?
> 
> I may have misunderstood something here.
> 
> ChrisA

It's nice walkaround for now and for linux. But how about my question and future? :)

[toc] | [prev] | [next] | [standalone]


#21740

Fromxliiv <tymoteusz.jankowski@gmail.com>
Date2012-03-16 01:19 -0700
Message-ID<19653171.562.1331885978787.JavaMail.geo-discussion-forums@vbbfw10>
In reply to#21735
> > Seems like an awfully obtuse way of doing things -- I don't really
> > want to have 15 different copies of Python (or even links), and it
> > requires root privleges every time you want to run a Python program
> > with the "correct" name.
> 
> Why do you need root? Can't you copy / link into your own home directory?
> 
> I may have misunderstood something here.
> 
> ChrisA

It's nice walkaround for now and for linux. But how about my question and future? :)

[toc] | [prev] | [next] | [standalone]


#21752

FromGrant Edwards <invalid@invalid.invalid>
Date2012-03-16 13:27 +0000
Message-ID<jjvf46$72m$1@reader1.panix.com>
In reply to#21735
On 2012-03-16, Chris Angelico <rosuav@gmail.com> wrote:
> On Fri, Mar 16, 2012 at 5:39 AM, Grant Edwards <invalid@invalid.invalid> wrote:
>> Seems like an awfully obtuse way of doing things -- I don't really
>> want to have 15 different copies of Python (or even links), and it
>> requires root privleges every time you want to run a Python program
>> with the "correct" name.
>
> Why do you need root? Can't you copy / link into your own home directory?

I was thinging about daemons and system-type stuff.

One possible problem with linking from one's home directory is that
home directories are often on different filesystems than /usr/bin (or
wherever python is).   Using a symlink doesn't work, the process name
still ends up as python2.6 (or whatever the real binary is called).

-- 
Grant Edwards               grant.b.edwards        Yow! Where do your SOCKS
                                  at               go when you lose them in
                              gmail.com            th' WASHER?

[toc] | [prev] | [next] | [standalone]


#21775

From"Prasad, Ramit" <ramit.prasad@jpmorgan.com>
Date2012-03-16 20:14 +0000
Message-ID<mailman.733.1331929775.3037.python-list@python.org>
In reply to#21752
> I was thinging about daemons and system-type stuff.
> 
> One possible problem with linking from one's home directory is that
> home directories are often on different filesystems than /usr/bin (or
> wherever python is).   Using a symlink doesn't work, the process name
> still ends up as python2.6 (or whatever the real binary is called).


Try a hardlink instead of symlink? It seems to work for me.


Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423

--
 
This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  

[toc] | [prev] | [next] | [standalone]


#21777

FromGrant Edwards <invalid@invalid.invalid>
Date2012-03-16 20:54 +0000
Message-ID<jk099o$5g$1@reader1.panix.com>
In reply to#21775
On 2012-03-16, Prasad, Ramit <ramit.prasad@jpmorgan.com> wrote:
>
>> One possible problem with linking from one's home directory is that
>> home directories are often on different filesystems than /usr/bin (or
>> wherever python is).  Using a symlink doesn't work, the process name
>> still ends up as python2.6 (or whatever the real binary is called).
> 
> Try a hardlink instead of symlink? It seems to work for me.

Not across different filesystems -- which was what I was talking
about.

-- 
Grant Edwards               grant.b.edwards        Yow! As President I have
                                  at               to go vacuum my coin
                              gmail.com            collection!

[toc] | [prev] | [next] | [standalone]


#22117

FromAdam Tauno Williams <awilliam@whitemice.org>
Date2012-03-24 11:24 -0400
Message-ID<mailman.952.1332604026.3037.python-list@python.org>
In reply to#21606

[Multipart message — attachments visible in raw view] — view raw

On Wed, 2012-03-14 at 07:43 -0700, xliiv wrote:
> Like the topic.. .
> I use Python a lot, both Windows and Linux, and it's little weird to
> have many python process without fast distinction which is what.

I'm not sure of my interpretation of your problem but if you want to set
the name of the running process in the process table, at least on
LINUX/UNIX, you can use the procname module available via PyPI.


[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web