<commit_before><commit_msg>A simple script that demonstrates how to spawn a memcached process inside a unittest. Dave.<commit_after>import socket
import subprocess
import time
import unittest

import memcache

class NonceStore(object):

    def __init__(self):
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        sock.bind(('', 0))
        port = sock.getsockname()[1]

        args = [
            "memcached",
            "-vv",
            "-p",
            str(port),
            "-U",
            str(port),
            "-l",
            "localhost"
        ]
        self.process = subprocess.Popen(args, shell=False)

        mc = memcache.Client(["localhost:%d" % port], debug=1)
        key = "some_key"
        value = None
        for attempt in range(0, 100):
            print mc.get_stats()
            print mc.set(key, "Some value")
            value = mc.get(key)
            print "%d >>>%s<<<" % (attempt, value)
            if value is not None:
                break
            time.sleep(1)

    def shutdown(self):
        self.process.terminate()
        
class TestCase(unittest.TestCase):

    @classmethod
    def setUpClass(cls):
        cls.nonce_store = NonceStore()

    @classmethod
    def tearDownClass(cls):
        cls.nonce_store.shutdown()
        cls.nonce_store = None

    def test_dave(self):
        self.assertTrue(True)

{'fraction_non_alphanumeric': 0.11463590483056957, 'fraction_numerical': 0.005767844268204758, 'mean_word_length': 1.8326530612244898, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4959065', 'n_tokens_mistral': 424, 'n_tokens_neox': 406, 'n_words': 99}