We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Terminal Width affects Lock identification under Centos 6.5
The luigi.lock.getpcmd function will return a shorter command line if the terminal is smaller in width. This can result in locks being misidentified as identical and can be a significant problem if your binary/scripts are located in deep paths.

Presumably there is some option that can be passed to ps to resolve this.

edit: It looks like if the ps command is changed to `ps x -wwo pid,args` that should take care of it.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `luigi/lock.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright 2012-2015 Spotify AB
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 #
17 """
18 Locking functionality when launching things from the command line.
19 Uses a pidfile.
20 This prevents multiple identical workflows to be launched simultaneously.
21 """
22 from __future__ import print_function
23 
24 import hashlib
25 import os
26 
27 from luigi import six
28 
29 
30 def getpcmd(pid):
31     """
32     Returns command of process.
33 
34     :param pid:
35     """
36     if os.name == "nt":
37         # Use wmic command instead of ps on Windows.
38         cmd = 'wmic path win32_process where ProcessID=%s get Commandline' % (pid, )
39         with os.popen(cmd, 'r') as p:
40             lines = [line for line in p.readlines() if line.strip("\r\n ") != ""]
41             if lines:
42                 _, val = lines
43                 return val
44     else:
45         cmd = 'ps -xo pid,args'
46         with os.popen(cmd, 'r') as p:
47             # Skip the column titles
48             p.readline()
49             for line in p:
50                 spid, scmd = line.strip().split(' ', 1)
51                 if int(spid) == int(pid):
52                     return scmd
53     # Fallback instead of None, for e.g. Cygwin where -o is an "unknown option" for the ps command:
54     return '[PROCESS_WITH_PID={}]'.format(pid)
55 
56 
57 def get_info(pid_dir, my_pid=None):
58     # Check the name and pid of this process
59     if my_pid is None:
60         my_pid = os.getpid()
61 
62     my_cmd = getpcmd(my_pid)
63 
64     if six.PY3:
65         cmd_hash = my_cmd.encode('utf8')
66     else:
67         cmd_hash = my_cmd
68 
69     pid_file = os.path.join(pid_dir, hashlib.md5(cmd_hash).hexdigest()) + '.pid'
70 
71     return my_pid, my_cmd, pid_file
72 
73 
74 def acquire_for(pid_dir, num_available=1, kill_signal=None):
75     """
76     Makes sure the process is only run once at the same time with the same name.
77 
78     Notice that we since we check the process name, different parameters to the same
79     command can spawn multiple processes at the same time, i.e. running
80     "/usr/bin/my_process" does not prevent anyone from launching
81     "/usr/bin/my_process --foo bar".
82     """
83 
84     my_pid, my_cmd, pid_file = get_info(pid_dir)
85 
86     # Check if there is a pid file corresponding to this name
87     if not os.path.exists(pid_dir):
88         os.mkdir(pid_dir)
89         os.chmod(pid_dir, 0o777)
90 
91     pids = set()
92     pid_cmds = {}
93     if os.path.exists(pid_file):
94         # There is such a file - read the pid and look up its process name
95         pids.update(filter(None, map(str.strip, open(pid_file))))
96         pid_cmds = dict((pid, getpcmd(pid)) for pid in pids)
97         matching_pids = list(filter(lambda pid: pid_cmds[pid] == my_cmd, pids))
98 
99         if kill_signal is not None:
100             for pid in map(int, matching_pids):
101                 os.kill(pid, kill_signal)
102         elif len(matching_pids) >= num_available:
103             # We are already running under a different pid
104             print('Pid(s)', ', '.join(matching_pids), 'already running')
105             return False
106         else:
107             # The pid belongs to something else, we could
108             pass
109     pid_cmds[str(my_pid)] = my_cmd
110 
111     # Write pids
112     pids.add(str(my_pid))
113     with open(pid_file, 'w') as f:
114         f.writelines('%s\n' % (pid, ) for pid in filter(pid_cmds.__getitem__, pids))
115 
116     # Make the file writable by all
117     if os.name == 'nt':
118         pass
119     else:
120         s = os.stat(pid_file)
121         if os.getuid() == s.st_uid:
122             os.chmod(pid_file, s.st_mode | 0o777)
123 
124     return True
125
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/luigi/lock.py b/luigi/lock.py
--- a/luigi/lock.py
+++ b/luigi/lock.py
@@ -42,7 +42,7 @@
                 _, val = lines
                 return val
     else:
-        cmd = 'ps -xo pid,args'
+        cmd = 'ps x -wwo pid,args'
         with os.popen(cmd, 'r') as p:
             # Skip the column titles
             p.readline()

{"golden_diff": "diff --git a/luigi/lock.py b/luigi/lock.py\n--- a/luigi/lock.py\n+++ b/luigi/lock.py\n@@ -42,7 +42,7 @@\n                 _, val = lines\n                 return val\n     else:\n-        cmd = 'ps -xo pid,args'\n+        cmd = 'ps x -wwo pid,args'\n         with os.popen(cmd, 'r') as p:\n             # Skip the column titles\n             p.readline()\n", "issue": "Terminal Width affects Lock identification under Centos 6.5\nThe luigi.lock.getpcmd function will return a shorter command line if the terminal is smaller in width. This can result in locks being misidentified as identical and can be a significant problem if your binary/scripts are located in deep paths.\n\nPresumably there is some option that can be passed to ps to resolve this.\n\nedit: It looks like if the ps command is changed to `ps x -wwo pid,args` that should take care of it.\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n#\n# Copyright 2012-2015 Spotify AB\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n#\n\"\"\"\nLocking functionality when launching things from the command line.\nUses a pidfile.\nThis prevents multiple identical workflows to be launched simultaneously.\n\"\"\"\nfrom __future__ import print_function\n\nimport hashlib\nimport os\n\nfrom luigi import six\n\n\ndef getpcmd(pid):\n    \"\"\"\n    Returns command of process.\n\n    :param pid:\n    \"\"\"\n    if os.name == \"nt\":\n        # Use wmic command instead of ps on Windows.\n        cmd = 'wmic path win32_process where ProcessID=%s get Commandline' % (pid, )\n        with os.popen(cmd, 'r') as p:\n            lines = [line for line in p.readlines() if line.strip(\"\\r\\n \") != \"\"]\n            if lines:\n                _, val = lines\n                return val\n    else:\n        cmd = 'ps -xo pid,args'\n        with os.popen(cmd, 'r') as p:\n            # Skip the column titles\n            p.readline()\n            for line in p:\n                spid, scmd = line.strip().split(' ', 1)\n                if int(spid) == int(pid):\n                    return scmd\n    # Fallback instead of None, for e.g. Cygwin where -o is an \"unknown option\" for the ps command:\n    return '[PROCESS_WITH_PID={}]'.format(pid)\n\n\ndef get_info(pid_dir, my_pid=None):\n    # Check the name and pid of this process\n    if my_pid is None:\n        my_pid = os.getpid()\n\n    my_cmd = getpcmd(my_pid)\n\n    if six.PY3:\n        cmd_hash = my_cmd.encode('utf8')\n    else:\n        cmd_hash = my_cmd\n\n    pid_file = os.path.join(pid_dir, hashlib.md5(cmd_hash).hexdigest()) + '.pid'\n\n    return my_pid, my_cmd, pid_file\n\n\ndef acquire_for(pid_dir, num_available=1, kill_signal=None):\n    \"\"\"\n    Makes sure the process is only run once at the same time with the same name.\n\n    Notice that we since we check the process name, different parameters to the same\n    command can spawn multiple processes at the same time, i.e. running\n    \"/usr/bin/my_process\" does not prevent anyone from launching\n    \"/usr/bin/my_process --foo bar\".\n    \"\"\"\n\n    my_pid, my_cmd, pid_file = get_info(pid_dir)\n\n    # Check if there is a pid file corresponding to this name\n    if not os.path.exists(pid_dir):\n        os.mkdir(pid_dir)\n        os.chmod(pid_dir, 0o777)\n\n    pids = set()\n    pid_cmds = {}\n    if os.path.exists(pid_file):\n        # There is such a file - read the pid and look up its process name\n        pids.update(filter(None, map(str.strip, open(pid_file))))\n        pid_cmds = dict((pid, getpcmd(pid)) for pid in pids)\n        matching_pids = list(filter(lambda pid: pid_cmds[pid] == my_cmd, pids))\n\n        if kill_signal is not None:\n            for pid in map(int, matching_pids):\n                os.kill(pid, kill_signal)\n        elif len(matching_pids) >= num_available:\n            # We are already running under a different pid\n            print('Pid(s)', ', '.join(matching_pids), 'already running')\n            return False\n        else:\n            # The pid belongs to something else, we could\n            pass\n    pid_cmds[str(my_pid)] = my_cmd\n\n    # Write pids\n    pids.add(str(my_pid))\n    with open(pid_file, 'w') as f:\n        f.writelines('%s\\n' % (pid, ) for pid in filter(pid_cmds.__getitem__, pids))\n\n    # Make the file writable by all\n    if os.name == 'nt':\n        pass\n    else:\n        s = os.stat(pid_file)\n        if os.getuid() == s.st_uid:\n            os.chmod(pid_file, s.st_mode | 0o777)\n\n    return True\n", "path": "luigi/lock.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n#\n# Copyright 2012-2015 Spotify AB\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n#\n\"\"\"\nLocking functionality when launching things from the command line.\nUses a pidfile.\nThis prevents multiple identical workflows to be launched simultaneously.\n\"\"\"\nfrom __future__ import print_function\n\nimport hashlib\nimport os\n\nfrom luigi import six\n\n\ndef getpcmd(pid):\n    \"\"\"\n    Returns command of process.\n\n    :param pid:\n    \"\"\"\n    if os.name == \"nt\":\n        # Use wmic command instead of ps on Windows.\n        cmd = 'wmic path win32_process where ProcessID=%s get Commandline' % (pid, )\n        with os.popen(cmd, 'r') as p:\n            lines = [line for line in p.readlines() if line.strip(\"\\r\\n \") != \"\"]\n            if lines:\n                _, val = lines\n                return val\n    else:\n        cmd = 'ps x -wwo pid,args'\n        with os.popen(cmd, 'r') as p:\n            # Skip the column titles\n            p.readline()\n            for line in p:\n                spid, scmd = line.strip().split(' ', 1)\n                if int(spid) == int(pid):\n                    return scmd\n    # Fallback instead of None, for e.g. Cygwin where -o is an \"unknown option\" for the ps command:\n    return '[PROCESS_WITH_PID={}]'.format(pid)\n\n\ndef get_info(pid_dir, my_pid=None):\n    # Check the name and pid of this process\n    if my_pid is None:\n        my_pid = os.getpid()\n\n    my_cmd = getpcmd(my_pid)\n\n    if six.PY3:\n        cmd_hash = my_cmd.encode('utf8')\n    else:\n        cmd_hash = my_cmd\n\n    pid_file = os.path.join(pid_dir, hashlib.md5(cmd_hash).hexdigest()) + '.pid'\n\n    return my_pid, my_cmd, pid_file\n\n\ndef acquire_for(pid_dir, num_available=1, kill_signal=None):\n    \"\"\"\n    Makes sure the process is only run once at the same time with the same name.\n\n    Notice that we since we check the process name, different parameters to the same\n    command can spawn multiple processes at the same time, i.e. running\n    \"/usr/bin/my_process\" does not prevent anyone from launching\n    \"/usr/bin/my_process --foo bar\".\n    \"\"\"\n\n    my_pid, my_cmd, pid_file = get_info(pid_dir)\n\n    # Check if there is a pid file corresponding to this name\n    if not os.path.exists(pid_dir):\n        os.mkdir(pid_dir)\n        os.chmod(pid_dir, 0o777)\n\n    pids = set()\n    pid_cmds = {}\n    if os.path.exists(pid_file):\n        # There is such a file - read the pid and look up its process name\n        pids.update(filter(None, map(str.strip, open(pid_file))))\n        pid_cmds = dict((pid, getpcmd(pid)) for pid in pids)\n        matching_pids = list(filter(lambda pid: pid_cmds[pid] == my_cmd, pids))\n\n        if kill_signal is not None:\n            for pid in map(int, matching_pids):\n                os.kill(pid, kill_signal)\n        elif len(matching_pids) >= num_available:\n            # We are already running under a different pid\n            print('Pid(s)', ', '.join(matching_pids), 'already running')\n            return False\n        else:\n            # The pid belongs to something else, we could\n            pass\n    pid_cmds[str(my_pid)] = my_cmd\n\n    # Write pids\n    pids.add(str(my_pid))\n    with open(pid_file, 'w') as f:\n        f.writelines('%s\\n' % (pid, ) for pid in filter(pid_cmds.__getitem__, pids))\n\n    # Make the file writable by all\n    if os.name == 'nt':\n        pass\n    else:\n        s = os.stat(pid_file)\n        if os.getuid() == s.st_uid:\n            os.chmod(pid_file, s.st_mode | 0o777)\n\n    return True\n", "path": "luigi/lock.py"}]}