From: Jiri Sevcik <jsevcik14@gmail.com>
To: git@vger.kernel.org
Subject: git-remote-fd problem
Date: Wed, 10 Sep 2014 15:29:00 +0200 [thread overview]
Message-ID: <CAOP4-939uAP2Tgofz01F40_Eb0F8GxBsU49HxNvAiyBCW6H08w@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 828 bytes --]
Hi!
I have problem with using git-remote-fd function. I create two local
pipes for communication for locally running process git pull. Then I
start git-upload-pack on remote side (this process is started in
different part of my code and it works correctly). Communication runs
successfully and when remote side finish, I want to close local pipes
to finish local process. I call close function to all of these pipes,
but unfortunatelly local process doesnt finish (in this moment
transfered data aresaved in /.git/object/pack folder in .pack files)
and hanging on. But if I kill child of this local process, downloaded
files are unpacked and files are created sucessfully. I think this way
is not so correct. Can someone help me and tell me what am I doing
wrong? Thank You. Code is in an attachement (its part of big system).
[-- Attachment #2: git_remote.py --]
[-- Type: text/x-python, Size: 2644 bytes --]
#create local pipes for cimmunication
local_r, local_w = os.pipe()
remote_r, remote_w = os.pipe()
#start local git process
client_process = subprocess.Popen("/usr/bin/git pull fd::{0},{1}".format(remote_r, local_w,), shell=True)
#start git process on remote side
remoteGit = proc.runDaemon("sudo git-upload-pack /tmp/testGit")
#set
epoll = select.epoll()
epoll.register(local_r, select.EPOLLIN)
#register from remote side
epoll.register(proc.fd, select.EPOLLIN)
while True:
events = epoll.poll(1)
for fd, event in events:
if fd == local_r:
#event on local process
if event & select.EPOLLIN:
rd = os.read(local_r, 5000)
if rd:
#write data to remote side
remoteGit.writeToChannel(rd)
else:
proc.writeError("Local socket write error")
client_process.kill()
return 1
else:
proc.writeError("Local socket error")
client_process.kill()
return 1
else:
if event & select.EPOLLIN:
#get all data from remote side
data = remoteGit.getAll()
remoteGit.stderrWrite()
if not data:
#remote side finished - close local pipes - local process wouldnt finish
os.close(local_r)
os.close(local_w)
os.close(remote_r)
os.close(remote_w)
#get local process pid and kill his child to finish git-remote-fd
gitPid = psutil.Process(client_process.pid).children()[0].pid
os.kill(gitPid, signal.SIGTERM)
return 0
want = len(data)
writed = 0
offset = 0
while(writed != want):
#write data from remote side to local process
wr = os.write(remote_w, data[offset:])
if(wr < 0):
proc.writeError("Local socket write error")
return 1
writed += wr
offset += wr
else:
proc.writeError("Remote socket error")
client_process.kill()
return -1
next reply other threads:[~2014-09-10 13:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-10 13:29 Jiri Sevcik [this message]
2014-09-10 14:47 ` git-remote-fd problem Ilari Liusvaara
[not found] ` <CAOP4-92U+oFJJw38LWNmTqPtKMT=MDq0Ay9FiaGV5je77aUNpg@mail.gmail.com>
2014-12-29 9:47 ` Fwd: " Jiri Sevcik
2014-12-29 19:36 ` Ilari Liusvaara
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAOP4-939uAP2Tgofz01F40_Eb0F8GxBsU49HxNvAiyBCW6H08w@mail.gmail.com \
--to=jsevcik14@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).