Skip to content

Commit f9e8278

Browse files
Fix #9 not closing OS file descriptor.
1 parent 6ccee5a commit f9e8278

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

webhooks.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
#
3-
# Copyright (C) 2014, 2015 Carlos Jenkins <carlos@jenkins.co.cr>
3+
# Copyright (C) 2014, 2015, 2016 Carlos Jenkins <carlos@jenkins.co.cr>
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.
@@ -24,7 +24,7 @@
2424
from json import loads, dumps
2525
from subprocess import Popen, PIPE
2626
from tempfile import mkstemp
27-
from os import access, X_OK, remove
27+
from os import access, X_OK, remove, fdopen
2828
from os.path import isfile, abspath, normpath, dirname, join, basename
2929

3030
import requests
@@ -72,7 +72,7 @@ def index():
7272
header_signature = request.headers.get('X-Hub-Signature')
7373
if header_signature is None:
7474
abort(403)
75-
75+
7676
sha_name, signature = header_signature.split('=')
7777
if sha_name != 'sha1':
7878
abort(501)
@@ -154,8 +154,8 @@ def index():
154154
return ''
155155

156156
# Save payload to temporal file
157-
_, tmpfile = mkstemp()
158-
with open(tmpfile, 'w') as pf:
157+
osfd, tmpfile = mkstemp()
158+
with fdopen(osfd, 'w') as pf:
159159
pf.write(dumps(payload))
160160

161161
# Run scripts

0 commit comments

Comments
 (0)