# Path: wxpy/utils/misc.py
# def start_new_thread(target, args=(), kwargs=None, daemon=True, use_caller_name=False):
#     """
#     启动一个新的进程，需要时自动为进程命名，并返回这个线程
#     
#     :param target: 调用目标
#     :param args: 调用位置参数
#     :param kwargs: 调用命名参数
#     :param daemon: 作为守护进程
#     :param use_caller_name: 为 True 则以调用者为名称，否则以目标为名称
# 
#     :return: 新的进程
#     :rtype: threading.Thread
#     """
# 
#     if use_caller_name:
#         # 使用调用者的名称
#         name = inspect.stack()[1][3]
#     else:
#         name = target.__name__
# 
#     logging.getLogger(
#         # 使用外层的 logger
#         inspect.currentframe().f_back.f_globals.get('__name__')
#     ).debug('new thread: {}'.format(name))
#     if PY2:
#         _thread = threading.Thread(
#             target=target, args=args, kwargs=kwargs,
#             name=name)
#         _thread.setDaemon(daemon)
#     else:
#         _thread = threading.Thread(
#             target=target, args=args, kwargs=kwargs,
#             name=name, daemon=daemon
#         )
#     _thread.start()
# 
#     return _thread


from binascii import crc32
from wxpy.utils import start_new_thread
        * 默认为空
    :param bool raise_for_unsupported:
        | 为 True 时，将为不支持的消息类型抛出 `NotImplementedError` 异常
    :param bool run_async: 是否异步执行，为 True 时不堵塞线程


    ::

        my_groups = [group1, group2, group3 ...]

        @bot.register(my_groups, except_self=False)
        def sync_my_groups(msg):
            sync_message_in_groups(msg, my_groups)

    """

    def process():
        for group in groups:
            if group == msg.chat:
                continue

            msg.forward(
                chat=group, prefix=prefix, suffix=suffix,
                raise_for_unsupported=raise_for_unsupported
            )

    if not prefix:
        prefix = forward_prefix(msg.member)

    if run_async:

# Path: wxpy/utils/misc.py
# def start_new_thread(target, args=(), kwargs=None, daemon=True, use_caller_name=False):
#     """
#     启动一个新的进程，需要时自动为进程命名，并返回这个线程
#     
#     :param target: 调用目标
#     :param args: 调用位置参数
#     :param kwargs: 调用命名参数
#     :param daemon: 作为守护进程
#     :param use_caller_name: 为 True 则以调用者为名称，否则以目标为名称
# 
#     :return: 新的进程
#     :rtype: threading.Thread
#     """
# 
#     if use_caller_name:
#         # 使用调用者的名称
#         name = inspect.stack()[1][3]
#     else:
#         name = target.__name__
# 
#     logging.getLogger(
#         # 使用外层的 logger
#         inspect.currentframe().f_back.f_globals.get('__name__')
#     ).debug('new thread: {}'.format(name))
#     if PY2:
#         _thread = threading.Thread(
#             target=target, args=args, kwargs=kwargs,
#             name=name)
#         _thread.setDaemon(daemon)
#     else:
#         _thread = threading.Thread(
#             target=target, args=args, kwargs=kwargs,
#             name=name, daemon=daemon
#         )
#     _thread.start()
# 
#     return _thread


# Path: wxpy/ext/sync_message_in_groups.py
from binascii import crc32
from wxpy.utils import start_new_thread

        * 默认为空
    :param bool raise_for_unsupported:
        | 为 True 时，将为不支持的消息类型抛出 `NotImplementedError` 异常
    :param bool run_async: 是否异步执行，为 True 时不堵塞线程


    ::

        my_groups = [group1, group2, group3 ...]

        @bot.register(my_groups, except_self=False)
        def sync_my_groups(msg):
            sync_message_in_groups(msg, my_groups)

    """

    def process():
        for group in groups:
            if group == msg.chat:
                continue

            msg.forward(
                chat=group, prefix=prefix, suffix=suffix,
                raise_for_unsupported=raise_for_unsupported
            )

    if not prefix:
        prefix = forward_prefix(msg.member)

    if run_async:

        start_new_thread(process, use_caller_name=True)