Exemplo n.º 1
0
def _main():
    thread_count = API.thread_count()
    assert thread_count >= 1

    threads = [_Task(API(thread_index))
               for thread_index in range(thread_count)]
    for thread in threads:
        thread.start()
    for thread in threads:
        thread.join()
Exemplo n.º 2
0
def _main():
    thread_count = API.thread_count()
    assert thread_count >= 1

    threads = [Task(API(thread_index), 'python_c', TerminateException)
               for thread_index in range(thread_count)]
    for thread in threads:
        thread.start()
    for thread in threads:
        thread.join()
Exemplo n.º 3
0
            self.__check_environment()
            # idle service with no subscriptions
            result = self.__api.poll()
            assert result == False
        except terminate_exception:
            pass
        except:
            traceback.print_exc(file=sys.stderr)
        print('terminate environment python_c')

    def __check_environment(self):
        user = os.environ.get('USER')
        assert user is not None
        assert os.environ[user] == 'user'
        assert os.environ[user + '_' + user] == 'user_user'
        assert os.environ[user + user] == 'useruser'
        assert os.environ[user + '123' + user] == 'user123user'
        assert os.environ['USER_D'] == 'user_$'
        assert os.environ['USER_'] == 'user_'


if __name__ == '__main__':
    thread_count = API.thread_count()
    assert thread_count >= 1

    threads = [Task(API(i)) for i in range(thread_count)]
    for t in threads:
        t.start()
    for t in threads:
        t.join()
Exemplo n.º 4
0
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
# DAMAGE.
#

import sys, os
sys.path.append(
    os.path.sep.join(
        os.path.dirname(os.path.abspath(__file__)).split(os.path.sep)[:-2] +
        ['api', 'python']))

from cloudi_c import API
from messaging import Task

if __name__ == '__main__':
    thread_count = API.thread_count()
    assert thread_count >= 1

    threads = [Task(API(i), i, 'python_c') for i in range(thread_count)]
    for t in threads:
        t.start()
    for t in threads:
        t.join()
Exemplo n.º 5
0
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
# DAMAGE.
#

import sys, os
sys.path.append(
    os.path.sep.join(
        os.path.dirname(os.path.abspath(__file__)).split(os.path.sep)[:-2] +
        ['api', 'python']))

from cloudi_c import API, terminate_exception
from http_req import Task

if __name__ == '__main__':
    thread_count = API.thread_count()
    assert thread_count >= 1

    threads = [
        Task(API(i), 'python_c', terminate_exception)
        for i in range(thread_count)
    ]
    for t in threads:
        t.start()
    for t in threads:
        t.join()
Exemplo n.º 6
0
 def __init__(self, thread_index):
     threading.Thread.__init__(self)
     self.__api = API(thread_index)
Exemplo n.º 7
0
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
# DAMAGE.
#

import sys, os
sys.path.append(
    os.path.sep.join(
        os.path.dirname(os.path.abspath(__file__))
               .split(os.path.sep)[:-2] + ['api', 'python']
    )
)

from cloudi_c import API, terminate_exception
from messaging import Task

if __name__ == '__main__':
    thread_count = API.thread_count()
    assert thread_count >= 1
    
    threads = [Task(API(i), i, 'python_c', terminate_exception)
               for i in range(thread_count)]
    for t in threads:
        t.start()
    for t in threads:
        t.join()