Skip to content

Commit

Permalink
timeval: Import ctypes Python library within a try statement.
Browse files Browse the repository at this point in the history
Older versions of Python do not have ctypes as a default installed
package. This patch puts the 'import ctypes' statement inside a try
statement.

This fixes a bug introduced by commit 8396f (timeval: Use monotonic
time in OVS Python timeval library).

Signed-off-by: Ryan Wilson <[email protected]>
Acked-by: Alex Wang <[email protected]>
  • Loading branch information
Ryan Wilson authored and yew011 committed May 31, 2014
1 parent 8396f80 commit 813c5ba
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions python/ovs/timeval.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import ctypes
import sys
import time

LIBRT = 'librt.so.1'
CLOCK_MONOTONIC = 1

class timespec(ctypes.Structure):
_fields_ = [
('tv_sec', ctypes.c_long),
('tv_nsec', ctypes.c_long),
]

try:
import ctypes

class timespec(ctypes.Structure):
_fields_ = [
('tv_sec', ctypes.c_long),
('tv_nsec', ctypes.c_long),
]

librt = ctypes.CDLL(LIBRT)
clock_gettime = librt.clock_gettime
clock_gettime.argtypes = [ctypes.c_int, ctypes.POINTER(timespec)]
Expand Down

0 comments on commit 813c5ba

Please sign in to comment.