• 0
Votes
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 195

Backtrace:

File: /home/u125378470/domains/lawhelpguru.org/public_html/application/views/question.php
Line: 195
Function: _error_handler

File: /home/u125378470/domains/lawhelpguru.org/public_html/application/controllers/Questions.php
Line: 416
Function: view

File: /home/u125378470/domains/lawhelpguru.org/public_html/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

I wrote a LockedList decoreator. How can i test it?

from threading import Lock
from threading import Thread

class LockedList(list):
    def __init__(self, *args, **kwargs):
        self._lock = Lock()
        super(LockedList, self).__init__(*args, **kwargs)

    def remove(self, elem):
        with self._lock:
            super(LockedList, self).remove(elem)

    def insert(self, i, elem):
        with self._lock:
            super(LockedList, self).insert(i, elem)

    def __contains__(self, elem):
        with self._lock:
            super(LockedList, self).__contains__(elem)


list = [2, 3, 4]
for i in range(100):
    t1 = threading.Thread(target=list.insert(i, i))
    if i % 2 == 0:
        t2 = threading.Thread(target=list.remove(i))

#10 output
for i in range(len(list)):
    if i % 10 == 0 and i != 0:
        print()
    print(list[i], end=' ')

I wrote this code for using locked_list decorator. But i don't know how to test it. Is it right code to test? I want to test list.insert() and list.remove() by using thread whether it causes race condition.