Bitcoin Forum
September 21, 2017, 01:54:50 AM *
News: Latest stable version of Bitcoin Core: 0.15.0.1  [Torrent]. (New!)
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: file_lock in python/Qt  (Read 1382 times)
genjix
Legendary
*
expert
Offline Offline

Activity: 1232


View Profile
February 12, 2011, 10:03:57 PM
 #1

Hey,

So I want to detect when bitcoind is running but that RPC server hasn't yet started up.

The way bitcoind checks whether it's already running is by using boost::file_lock
http://www.boost.org/doc/libs/1_35_0/boost/interprocess/sync/file_lock.hpp

Any ideas how to use this in python? I could create my own binding for python but I'd rather not have a compilable dependency for such a minor thing.

The problem with checking a systems processes is that it's unreliable to assume the program is always called bitcoin (i.e different server implementations).

I tried a different file-lock library:
Code:
$ bitcoind
$ sudo apt-get install python-lockfile
$ python
import lockfile
lock = lockfile.FileLock('.bitcoin')
with lock:
    print lock.path

'.bitcoin'
$ cd .bitcoin/
$ python
import lockfile
lock = lockfile.FileLock('.lock')
with lock:
    print lock.path

'.lock'

Any ideas how to do this? Must be cross-platform. File locking is an OS function, so maybe I'm not using the correct file?
1505958890
Hero Member
*
Offline Offline

Posts: 1505958890

View Profile Personal Message (Offline)

Ignore
1505958890
Reply with quote  #2

1505958890
Report to moderator
1505958890
Hero Member
*
Offline Offline

Posts: 1505958890

View Profile Personal Message (Offline)

Ignore
1505958890
Reply with quote  #2

1505958890
Report to moderator
1505958890
Hero Member
*
Offline Offline

Posts: 1505958890

View Profile Personal Message (Offline)

Ignore
1505958890
Reply with quote  #2

1505958890
Report to moderator
          ▄█████▄
        ▄█████████▄
      ▄████▀   ▀████▄
    ▄████▀   ▄ ▄█▀████▄
  ▄████▀   ▄███▀   ▀████▄
▄████▀   ▄███▀   ▄   ▀████▄
█████   ███▀   ▄███   █████
▀████▄   ▀██▄▄███▀   ▄████▀
  ▀████▄   ▀███▀   ▄████▀
    ▀████▄       ▄████▀
      ▀████▄   ▄████▀
        ▀███  ████▀
          ▀█▄███▀
.
|
.
|
          ▄█████▄
        ▄█████████▄
      ▄████▀   ▀████▄
    ▄████▀   ▄ ▄█▀████▄
  ▄████▀   ▄███▀   ▀████▄
▄████▀   ▄███▀   ▄   ▀████▄
█████   ███▀   ▄███   █████
▀████▄   ▀██▄▄███▀   ▄████▀
  ▀████▄   ▀███▀   ▄████▀
    ▀████▄       ▄████▀
      ▀████▄   ▄████▀
        ▀███  ████▀
          ▀█▄███▀
unthy
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1505958890
Hero Member
*
Offline Offline

Posts: 1505958890

View Profile Personal Message (Offline)

Ignore
1505958890
Reply with quote  #2

1505958890
Report to moderator
1505958890
Hero Member
*
Offline Offline

Posts: 1505958890

View Profile Personal Message (Offline)

Ignore
1505958890
Reply with quote  #2

1505958890
Report to moderator
1505958890
Hero Member
*
Offline Offline

Posts: 1505958890

View Profile Personal Message (Offline)

Ignore
1505958890
Reply with quote  #2

1505958890
Report to moderator
genjix
Legendary
*
expert
Offline Offline

Activity: 1232


View Profile
February 13, 2011, 01:36:09 AM
 #2

hrrnnngg... back to the top
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!