Diff of /mmaction/utils/misc.py [000000] .. [6d389a]

Switch to unified view

a b/mmaction/utils/misc.py
1
# Copyright (c) OpenMMLab. All rights reserved.
2
import ctypes
3
import random
4
import string
5
6
7
def get_random_string(length=15):
8
    """Get random string with letters and digits.
9
10
    Args:
11
        length (int): Length of random string. Default: 15.
12
    """
13
    return ''.join(
14
        random.choice(string.ascii_letters + string.digits)
15
        for _ in range(length))
16
17
18
def get_thread_id():
19
    """Get current thread id."""
20
    # use ctype to find thread id
21
    thread_id = ctypes.CDLL('libc.so.6').syscall(186)
22
    return thread_id
23
24
25
def get_shm_dir():
26
    """Get shm dir for temporary usage."""
27
    return '/dev/shm'